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

How to implement time function conversion in php

coldplay.xixi
coldplay.xixiOriginal
2020-08-21 13:15:361806browse

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”)

and then use

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

to convert to date. .

2. Convert timestamp to date

Time stamp conversion function:

date("Y-m-d H:i:s",time())
  • "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())

is converted to:

2010-07-18 18:42:48 
date("Y-m-d",time())

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!

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