Php date and time knowledge ,. Php date, time-related knowledge, unix timestamp: the number of seconds that have elapsed since, January 1, January 1, 1970 to the current time. 1. convert a date to a UNIX timestamp mktime (): you can automatically learn about php date and time,
Unix timestamp: the number of seconds that have elapsed since, January 1, January 1, 1970 to the current time.
1. convert a date to a UNIX timestamp
Mktime (): Automatically corrects out-of-range input.
Prototype: mktime (hour, minute, second, month, day, year );
Instance:
2. parse the date and time of English text into unix timestamp
Strtotime ()
Prototype: strtotime (time, now)
Example: use strtotime () to compile a countdown program for the anniversary
Extended: date calculation
The simplest way to calculate the length of the two dates is to calculate the difference between the two UNIX timestamps.
Example: in the php script, the birth date from html form submission is received to calculate the user's age.
Date and time formatting output
When the date and time need to be saved or calculated, the UNIX timestamp is used as the standard format.
Disadvantage: poor readability of unix timestamp format
Solution: Call date () to format the local time and date
Syntax date (format, timestamp) format a local time and date
---------------------------------
Notes:
References: PHP
Unix timestamp: the number of seconds that have elapsed since, January 1, January 1, 1970. 1. convert the date to UNIX timestamp mktime (): it can be automatically corrected...