Home  >  Article  >  Backend Development  >  php determine day of week

php determine day of week

王林
王林Original
2019-09-30 17:44:193494browse

php determine day of week

PHP determines what day of the week it is today

php’s date() function is very powerful, and you can use it rationally Various parameters can meet various needs in our daily development. Today I will talk about how to use PHP to determine what day of the week it is today.

PHP date() parameter description

The w parameter is mainly used here. The explanation of this parameter is: w represents the day of the week, and the number represents 0 (meaning Sunday) to 6 (meaning Saturday), with this everything is very simple.

Example:

//php获取今天是星期几
function getWeek($unixTime=''){
$unixTime=is_numeric($unixTime)?$unixTime:time();
$weekarray=array('日','一','二','三','四','五','六');
return '星期'.$weekarray[date('w',$unixTime)];
 
echo getWeek();

Recommended tutorial:PHP video tutorial

The above is the detailed content of php determine day of week. 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