Date and time in PHP

Source: Internet
Author: User
Tags local time sunrise time

Date and time
1.UNIX time Stamp
Greenwich Mean Time as a 32-bit integer
This unix timestamp integer is the number of seconds from January 1, 1970 0:0 0 seconds (computer-based) to now
Function: Convenient for us to calculate and use (participate in calculation)
2. Get the date and time in PHP
Time () returns the current UNIX timestamp
GETDATE () Get Date/time information The return value is an associative array
Gettimeofday () Gets the current time
Date_sunrise () returns the Sunrise time for a given date and place
Date_sunset () returns the sunset time for a given date and place
3. Formatted output of date and time
Date () format a local time/date
4. Turn the date and time into a UNIX timestamp
Mktime () timestamp of date obtained
5. Modify the PHP default time zone
Date.timezone= in the php.ini
You can set the time zone with the Date_default_timezone_set () function
6. Use a subtle calculation of the time the PHP script executes

<?PHP//time () returns the current UNIX timestampEcho  Time()." <br> ";Echo"<pre>";Print_r(getdate());Echo"</pre><br>";Echo Date("Y-m-d h:i:s", Time())." <br> ";Echo Date("Y-m-d h:i:s"). " <br> ";Echo Mktime()." <br> ";//Set the default time zone to use. Available from PHP 5.1Date_default_timezone_set ("PRC");Echo Date("Y-m-d h:i:s"). " <br> ";?>

Date and time in PHP

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.