How to change the time format in php

藏色散人
Release: 2023-03-10 20:26:01
Original
1925 people have browsed it

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']));
Copy after login

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)
Copy after login

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)
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!