Date and time processing technology php's time concept unix timestamp date and time processing 1. php's time concept in php, date and time functions depend on the server's region settings, php defaults to the standard Greenwich mean time, that is, the zero time zone. Therefore, to obtain the current local time, you must update the value of SyntaxHighlighter. all ();
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"