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.