Home >Backend Development >PHP Tutorial >How to use php date function
php The date function is used to format the timestamp into a more readable date and time. The syntax of this function is "date(format, timestamp)". The format parameter cannot be omitted. It specifies how to Format date or time.
How to use the php date() function?
php The date() function formats the timestamp into a more readable date and time.
Syntax:
date(format,timestamp)
Parameters:
format: Required. Specifies the format of the timestamp.
timestamp: Optional. Specify timestamp. The default is the current time and date.
Note: The format parameters of the date() function are required, and they specify how to format the date or time.
php date() function example 1
<?php echo date("Y-m-d",1335283200); ?>
Output:
2012-04-25
php date() function example 2
<?php //将时间戳以年月日时分秒的形式输出 echo date("Y-m-d H:i:s",1335283200); ?>
Output:
2012-04-24 16:00:00
This article is about how to use the date function. I hope it will be helpful to friends who need it!
The above is the detailed content of How to use php date function. For more information, please follow other related articles on the PHP Chinese website!