1, convert to timestamp function: Strtotime ()
This function takes a string containing the U.S. English date format and attempts to resolve it to a Unix timestamp, with a value relative to the time given by the now parameter, and the current time of the system if this parameter is not provided.
<?php/** * Created by Phpstorm. * user:58 * DATE:2016/9/19 * time:15:56 */echo @strtotime ("Now"); Echo ' <br/> '; Echo @strtotime ("September 2015" Echo ' <br/> ', echo @strtotime (' +1 Day '), Echo ' <br/> ', echo @strtotime (' +1 week '); Echo ' <br/> '; echo @ Strtotime (' +1 Week 2 days 4 hours 2 seconds '); Echo ' <br/> '; Echo @strtotime (' next Thursday '); Echo ' <br/> '; echo @strtotime (' last Monday ');
Note: If the given year is a two-digit format, its value of 0-69 means that 2000-2069,70-100 represents 1970-2000.
2, convert timestamp to date format, date (' y-m-d h:i:s ', $str)
<?php/** * Created by Phpstorm. * user:58 * DATE:2016/9/19 * time:15:56 * * $str = ' 1474274570 '; Echo Date (' y-m-d h:i:s ', $str);
Date function in PHP