Home > Backend Development > PHP Problem > php determine day of week

php determine day of week

王林
Release: 2023-02-25 18:12:02
Original
3591 people have browsed it

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();
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template