In php, the strtotime () function resolves the datetime description of any English text to a Unix timestamp, which is also frequently used, if you have any need, refer to using strtotime to convert Time strings of various formats into timestamps.
Convert regular time format
Echo date ('Y-m-d H: I: S', strtotime ('2017-01-30 ')). PHP_EOL; echo date ('Y-m-d H: I: S', strtotime ('20140901 ')). 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