Home  >  Article  >  Backend Development  >  How to get the day of the week today is in PHP

How to get the day of the week today is in PHP

Guanhui
GuanhuiOriginal
2020-05-12 16:50:483814browse

How to get the day of the week today is in PHP

How to get the day of the week today in PHP

In PHP, you can use the function "date()" to get the day of the week today. This function Its function is to format a local time or date. When using it, just pass the first parameter into the string "w", which means to get the day of the week. If the return value is 0, it means Sunday.

Sample code:

$weekarray=array("日","一","二","三","四","五","六"); //先定义一个数组
echo "星期".$weekarray[date("w")];

//获取指定日期
$weekarray=array("日","一","二","三","四","五","六");
echo "星期".$weekarray[date("w",strtotime("2011-11-11"))];

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to get the day of the week today is in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn