In php, you can modify the time format through "date("Y-m-d",strtotime($list['pubdate']));". This statement means that after putting the time into strtotime as a timestamp, use date () Conversion format.
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
How to change the time format in php?
Modify time format:
date("Y-m-d",strtotime($list['pubdate']));
Learning explanation: Put the time into strtotime as a timestamp and use date() to convert the format.
PHP strtotime() function
The strtotime() function parses any English text datetime description into a Unix timestamp.
Syntax
strtotime(time,now)
time specifies the time string to be parsed.
now is the timestamp used to calculate the return value. If this parameter is omitted, the current time is used.
PHP Date() The function can format the timestamp into a more readable date and time.
Syntax
date(format,timestamp)
format Required. Specifies the format of the timestamp.
timestamp Optional. Specify timestamp. The default is the current date and time.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to change the time format in php. For more information, please follow other related articles on the PHP Chinese website!