Home > Article > Backend Development > What is the meaning of php date(z)
In PHP, the meaning of "date(z)" is to format the current local time and calculate the day of the year (from 0 to 365) when the current local time is. If the date() function sets the second parameter, the syntax "date("z",timestamp)", the day of the year for the specified timestamp can be calculated.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, the date() function will format Converts the local date and time and returns a formatted date string.
Grammar:
date(format,timestamp);
format: Specifies the format of the output date string. When the value is "z", it indicates the day of the year. (from 0 to 365)
timestamp: Specifies an integer Unix timestamp. The default is the current local time (time()).
Example:
<?php header("Content-type:text/html;charset=utf-8"); $time=date("z")+1; echo "是一年的第".$time."天<br>"; $time = date("z",strtotime("2021-01-01"))+1; echo "是一年的第".$time."天"; ?>
Because the number of days starts from 0, you can add 1 to it
The output result is:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What is the meaning of php date(z). For more information, please follow other related articles on the PHP Chinese website!