How PHP gets localization time

Source: Internet
Author: User
Tags time 0
How PHP gets localization time

// Local time zone identifier
$ Timezone_identifier = "Asia/hong_kong ";
// Set the local default time zone for all date and time functions in a script
Date_default_timezone_set ($ timezone_identifier );
$ Atoday = getdate ();

In this way, the date and time of the region can be obtained because the default acquisition is Greenwich Mean Time 0 time zone.
You can also set PHP. ini
[Date]
; Defines the default timezone used by the date functions
Date. timezone =
"Asia/hong_kong"

Restart Apache
$ Atoday = getdate ();
In this way, you can obtain the date and time of the region. I use the time () and getdate () functions to obtain the time and system time.CodeAs follows:

<? PHP
$ Timestamp = Time ();
Echo $ timestamp. "<br> ";
$ Date_time_array = getdate ($ timestamp );
$ Datetime = $ date_time_array ["year"]. "-". $ date_time_array ["mon"]. "-". $ date_time_array ["mday"]. "";
$ Datetime = $ datetime. $ date_time_array ["hours"]. ":". $ date_time_array ["Minutes"]. ":". $ date_time_array ["seconds"];
Echo $ datetime;
?>

Input content:
1142992778
2006-3-22 1:59:38

Int time (void)
Returns the current timestamp, that is, from 00:00:00, January 1, January 1, 1970 to the current number of seconds.
Array getdate (INT [timestamp]) is based on the date and time returned by timestamp.

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.