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