Powerful time conversion functions of php, strtotime function of php
You can use strtotime to convert time strings of various formats into timestamps.
Convert regular time format
echo date('Y-m-d H:i:s', strtotime('2016-01-30 18:00')).PHP_EOL;echo date('Y-m-d H:i:s', strtotime('20160130180001')).PHP_EOL;
Change natural time Description
// Yesterday echo date ('Y-m-d H: I: s', strtotime ('yesterday ')). PHP_EOL; // last week echo date ('Y-m-d H: I: s', strtotime ('Last week ')). PHP_EOL; // this week's start time echo date ('Y-m-d H: I: s', strtotime ('This week midnight ')). PHP_EOL; // this month start time echo date ('Y-m-d H: I: s', strtotime ('first day of this month midnight ')). PHP_EOL; // calculate the relative time echo date ('Y-m-d H: I: s', strtotime ('+ 1 month ')). PHP_EOL;
Complete php time Description document can refer to http://php.net/manual/zh/datetime.formats.relative.php
Articles you may be interested in:
- PHP strtotime Functions
- Php in-depth understanding of the use of strtotime Functions
- PHP timestamp strtotime () usage and tips
- Php uses the strtotime and date functions to determine whether the date is valid for code sharing
- PHP obtains the date (strtotime, date) of the previous month, next month, and this month)
- Php uses the date and strtotime functions to output the method of specifying a date
- Js imitates strtotime () and date () functions in php.
- PHP uses strtotime to obtain the date of the previous month, next month, and this month