Home > Article > Backend Development > How to get and display the day of the week in php
php implements the method of getting the displayed day of the week: first create a PHP sample file; then define an array, and get the day of the week through "date("w")"; and finally perform display processing.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
php obtains the displayed day of the week through the date function
A simple PHP method to display the day of the week. To determine what day of the week today is, you can know the day of the week through the following Several operations.
echo date("l");//date就可以获取英文的星期比如Sunday echo date("w");//这个可以获取数字星期比如123,注意0是星期日
You can define an array, get the day of the week through date("w"), and then display the processing
$weekarray=array("日","一","二","三","四","五","六"); //先定义一个数组 echo "星期".$weekarray[date("w")];
You can also specify the day of the week by adding a second parameter, Then it is displayed.
$weekarray=array("日","一","二","三","四","五","六"); //先定义一个数组 echo "星期".$weekarray[date("w","2016-03-03")];
Recommended: "PHP Video Tutorial"
The above is the detailed content of How to get and display the day of the week in php. For more information, please follow other related articles on the PHP Chinese website!