The time function in PHP

Source: Internet
Author: User
Tags time zones london time zone set time time and date
This article introduces the content of PHP in the time function, has a certain reference value, now share to everyone, the need for friends can refer to

Time function
Time and date
Time stamp
1, he is an integer
2, from January 1 to 1970 ~ Now the Integer (Greenwich (London) Time 1970 years of January 1 0:0 0 seconds start calculation)
Why use timestamps, for ease of calculation
Common time functions
Time () gets the current timestamp
Date (' Format ', ' timestamp ') is used for some calculations to know the current time information
Note: If the timestamp is not provided, then the current timestamp is indicated
Symbolic meanings in the format
Y year
M month
D Date
H hours
I minute
s S
Time
PHP is a world-wide language. The default 0 time zone, London time zone. China, East Eight, east of London 8 time zones
Ways to change the time zone
1. Modify the configuration file
date.timezone= corresponding time zone in the configuration file
Asia/shanghai
PRC China
Etc/gmt-8
The current time zone is 8 hours faster than the standard time zone, which is the current time zone minus 8 hours equals GMT
2. Use function settings
Date_default_timezone_set (' PRC ') set time zone
Date_default_timezone_get () Get time zone
Note: No matter what the time zone is, your timestamp will be the same, the setting is just the time to set the display.
Other functions
Mktime (hours, minutes, seconds, months, days, years)
strtotime () resolves the datetime description of any English text to a UNIX timestamp
Strtotime (' +1 day ') + 1 days
+1 Week + 1 weeks
+1 Week 2 days 4 hours 2seconds
Time and date
Time stamp
1, he is an integer
2, from January 1 to 1970 ~ Now the Integer (Greenwich (London) Time 1970 years of January 1 0:0 0 seconds start calculation)
Why use timestamps, for ease of calculation
Common time functions
Time () gets the current timestamp
Date (' Format ', ' timestamp ') is used for some calculations to know the current time information
Note: If the timestamp is not provided, then the current timestamp is indicated
Symbolic meanings in the format
Y year
M month
D Date
H hours
I minute
s S
Time
PHP is a world-wide language. The default 0 time zone, London time zone. China, East Eight, east of London 8 time zones
Ways to change the time zone
1. Modify the configuration file
date.timezone= corresponding time zone in the configuration file
Asia/shanghai
PRC China
Etc/gmt-8
The current time zone is 8 hours faster than the standard time zone, which is the current time zone minus 8 hours equals GMT
2. Use function settings
Date_default_timezone_set (' PRC ') set time zone
Date_default_timezone_get () Get time zone
Note: No matter what the time zone is, your timestamp will be the same, the setting is just the time to set the display.
Other functions
Mktime (hours, minutes, seconds, months, days, years)
strtotime () resolves the datetime description of any English text to a UNIX timestamp
Strtotime (' +1 day ') + 1 days
+1 Week + 1 weeks
+1 Week 2 days 4 hours 2seconds

Related recommendations:

PHP time-to-rub conversion time remaining

PHP timestamp functions in a detailed

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.