Home  >  Article  >  Backend Development  >  How to determine what day of the week today is in php

How to determine what day of the week today is in php

藏色散人
藏色散人Original
2020-09-02 09:32:392522browse

php method to determine what day of the week today is: first create a PHP sample file; then get today's date through the "$w=date('w');" method; finally use "$week=array( )" method to determine what day of the week today is.

How to determine what day of the week today is in php

Recommendation: "PHP Video Tutorial"

php It is very difficult to determine what day of the week it is today

Simple, as long as you are familiar enough with the php date function, it only takes one sentence! See for yourself below!

Code

<?php
$w=date(&#39;w&#39;);
$week=array(
	"0"=>"星期日",
	"1"=>"星期一",
	"2"=>"星期二",
	"3"=>"星期三",
	"4"=>"星期四",
	"5"=>"星期五",
	"6"=>"星期六"
);
echo &#39;今天是&#39;.$week[$w];

date() function formats the local date and time and returns the formatted date string.

Grammar

date(format,timestamp);

The above is the detailed content of How to determine what 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