Home > Backend Development > PHP Problem > How to implement time function conversion in php

How to implement time function conversion in php

coldplay.xixi
Release: 2023-03-04 22:18:01
Original
1830 people have browsed it

php method to implement time function conversion: 1. Obtain the timestamp, the code is [$todaytime=strtotime("today")]; 2. The timestamp conversion function, the code is [date("Y-m-d H: i:s",time())].

How to implement time function conversion in php

[Related learning recommendations: php graphic tutorial]

php method to implement time function conversion :

1.php to get the timestamp of today's zero o'clock. To get the unix timestamp of zero o'clock, you can use

$todaytime=strtotime(“today”)
Copy after login

and then use

date("Y-m-d H:i",$todaytime)
Copy after login

to convert to date. .

2. Convert timestamp to date

Time stamp conversion function:

date("Y-m-d H:i:s",time())
Copy after login
Copy after login
  • "Y-m-d H:i:s" is the converted date format,

  • ##time() is the timestamp to obtain the current time.

If it is date("Y-m-d H:i:s",time()), the hours, minutes and seconds will be displayed together;

If it is date("Y-m-d " , time()), only displays the year, month and day. For example:

date("Y-m-d H:i:s",time())
Copy after login
Copy after login

is converted to:

2010-07-18 18:42:48 
date("Y-m-d",time())
Copy after login
Related learning recommendations:

php programming (video)

The above is the detailed content of How to implement time function conversion in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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