- date_default_timezone_set('PRC'); //Set the time zone
- $date1 = strtotime('2015-01-01'); //Convert date to timestamp
- $date2 = time( ); //Get the timestamp of the current time
- $nowtime=strftime("%Y-%m-%d",$date2); //Format the output date
- $days=round(($date1-$ date2)/3600/24); //Rounding
- echo "Today is".$nowtime."";
- echo "
distance ".strftime("%Y-%m-%d ",$date1)."Also".$days."Days
";
-
- echo "Current time" . date("Y-m-d h:i:s",strtotime("now")). "
";
- echo "Time the day after tomorrow" . date("Y-m-d h:i:s",strtotime("+2 day")). "
";
- echo "Time next week" . date("Y-m-d h :i:s",strtotime("+1 week")). "
";
- echo "Next month's time" . date("Y-m-d h:i:s",strtotime("+1 month ")). "
";
- echo "Next year's time" . date("Y-m-d h:i:s",strtotime("+1 year")). "
";
- echo "The time in 2 days, 4 hours and 2 seconds next week" . date("Y-m-d h:i:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "
";
- echo "Next Thursday time" . date("Y-m-d h:i:s",strtotime("next thursday")). "
";
- echo "Last Monday time" . date ("Y-m-d h:i:s",strtotime("last monday")). "
";
- echo "2015-01-04 3 days later" . date("Y-m-d h:i: s",strtotime("+3 day",strtotime('2015-01-04')));
-
- ?>
Copy code
|