PHP series (eight) PHP date time

Source: Internet
Author: User

1, Date_default_timezone_set ("PRC");// Set default time zone

$t = time ();

Echo $t;

$d = Date("Y year M D Day H:i:s", $t);//Thedata function formats the timestamp as a more readable date and time.

Echo $d;

Display as: 14,646,786,492,016 May 31 15:10:49


2, Microtime the (true) function returns the current Unix timestamp and the number of microseconds.

$t 1 = microtime (true);
// ... Execute code ...
$t 2 = Microtime (true);
Echo ' time-consuming '. Round ($t 2-$t 1,3). ' Seconds ';


3, Strtotime () function to parse the datetime description of any English text into a UNIX timestamp

echo Date (' y-m-d h:i:s ', Strtotime (' Now ') +8*60*60);
Result: 2013-04-05 03:15:02

Gets the timestamp of the current time!


4, Mktime () function returns the Unix timestamp of a date

echo Date ("M-d-y", mktime (0, 0, 0, 12, 32,1997));

Display as: jan-01-1998


This article is from the "Linux Warden" blog, so be sure to keep this source http://sswqzx.blog.51cto.com/2494644/1968863

PHP series (eight) PHP date time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.