Date and Time Processing Technology
Time Concept of php
Unix Timestamp
Date and Time Processing
1. php time concept
In php, the date and time functions depend on the region settings of the server. By default, php adjusts the standard Greenwich Mean Time (that is, the Zero Time Zone. Therefore, to obtain the current local time, you must change the time zone settings in php. There are two ways to change the time zone. One is set in the php. ini file and the other is set through the date_default_timezone_set function.
Set the time zone in the php. ini file, date. timezone = xxx
The date_default_timezone_set () function sets the time zone. This function is used before the date and time functions. If the server uses a zero time zone, you cannot directly modify the php. ini file. You can only set the time zone through the date_default_timezone_Set () function.
2. Timestamp
1. Obtain the timestamp of any date and time
The mktime () function converts a time to a unix timestamp. The mktime () function returns a unix timestamp Based on the given parameter. The parameter can be omitted from the right to the left. Any omitted parameter will be set to the local date, the current value of time (that is, if no parameter is set, the mktime () function obtains the current local date and time ). Mktime (hours, minutes, seconds, months, days, years, and hours)
Mktime () obtains the timestamp of the current time without setting any parameters.
2. Get the current timestamp. php also provides the time () function to get the timestamp of the current time.
3. Convert date and time to unix Timestamp
The strtotime () function parses the date description of any English text into a unix timestamp.
3. Processing Date and Time
Date and time processing can be divided into formatting date and time, obtaining date and time information, obtaining localized Date and Time validation date and time validity.
The date () function is used to format the local date and time,
The getdate () function returns the date and time information in array format. If there is no timestamp, the current time prevails.
Verify the validity of the date and time, checkdate ()
Author "Technology is King"