Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of PHP date-time function

Shulou Source: shulou.com Published: 2022-06-03 17:44:29 11月13日 Update

Editor to share with you the PHP date-time function example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

1. Date_default_timezone_set ("PRC"); / / set the default time zone

$t = time ()

Echo $t

$d = date ("M / d / Y H:i:s", $t); / / the data function formats the timestamp into a more readable date and time.

Echo $d

Displayed as: 1464678649 15:10:49 on 31 May 2016

2. The Microtime (true) function returns the current Unix timestamp and microseconds.

$T1 = microtime (true)

/ /... Execute the code.

$T2 = microtime (true)

Echo 'time-consuming' .round ($t _ 2murf _ t _ 1pr _ 3). Seconds'

3. The strtotime () function parses the date-time description of any English text into a Unix timestamp.

Echo date ('Y-m-d now') + 8' 60')

Result: 2013-04-05 03:15:02

/ / get the timestamp of the current time!

4. The mktime () function returns the Unix timestamp of a date.

Echo date ("M-d-Y", mktime (0,0,0,12,32))

Displayed as: Jan-01-1998

The above is all the contents of the article "sample Analysis of PHP date-time function". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Time function date article example analysis content not much code most text time zone more format knowledge results industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn NVidia Docker MariaDB