The conversion between timestamp and date in PHP is achieved through the data () function and the Strtotime () function, and the data function implements the timestamp to date, and the Strtotime function implements the date-to-time stamp.
Timestamp to date ()
<?phpvar_dump (Time ()); Gets the current timestamp int (1502245603)
Format required. Specifies the format of the timestamp.
Timestamp is optional. Time stamp is specified. The default is the current time and date
Timestamp to date can be implemented with date (' Y-m-s h:i:s ', specific timestamp).
Y: Year (four-digit) uppercase
M: Month (two digits, first less than 0) lowercase
D: Day (two digits, first less than 0) lowercase
H: Hour with first zero 24 hour format
H: Hour with First zero 12 hour format
I: minutes with first zero
S: Seconds with First zero (00-59)
A: Lowercase noon and afternoon (AM or PM)
Case sensitivity is important, such as the following example:
Var_dump (Date (' y-m-d h:i:s ', 1502204401)); H 24-hour 2017-08-08 23:00:01 var_dump (Date (' y-m-d h:i:s ', 1502204401)); H 12-hour 2017-08-08 11:00:01
Date turn timestamp strtotime ()
Strotime is a very flexible and intelligent function that can recognize Chinese, English, and digital, let's feel it.
<?phpecho strtotime ("Now"), "\ n", Echo Strtotime ("Ten September"), "\ n"; Echo strtotime ("+1 Day"), "\ n"; Echo Strtotime ("+1 Week"), "\ n"; Echo strtotime ("+1 Week 2 days 4 hours 2 Seconds"), "\ n"; Echo strtotime ("next Thursday"), "\ n"; Echo Strtotime ("Last Monday"), "\ n"; Echo strtotime ("20170808 23:00:01"), "\ n";? >