How PHP gets localization time ____php

Source: Internet
Author: User
Tags datetime getdate local time
How PHP gets the localization time
local time zone identifier
$timezone _identifier = "Asia/hong_kong";
Set the local default time zone for all date-time functions in a script
Date_default_timezone_set ($timezone _identifier);
$aToday = getdate ();

This can be achieved by the date time of the region because the default is GMT 0 time zone
You can also set the php.ini
[Date]
; Defines the default timezone used by the date functions
Date.timezone =
"Asia/hong_kong"

Restart Apache
$aToday = getdate ();
This can be achieved in the region date time I use the time () and the GETDATE () function to get different times and system time, consult the master, my Code is as 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;
?>

The input reads:
1142992778
2006-3-22 1:59:38 int time (void)
is to return the current timestamp, that is, from January 1, 1970 00:00:00 to the current number of seconds
The 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.