Home  >  Article  >  Backend Development  >  How to change the time format in php

How to change the time format in php

藏色散人
藏色散人Original
2021-06-24 10:14:111921browse

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.

How to change the time format in php

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!

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