-
- date_default_timezone_set("Asia/Hong_Kong");
- $time1 = strtotime(date("Y-m-d H:i:s")); //Current system time
- $time2 = strtotime( "2013-2-10 17:10:00"); //Holiday time
- $time3 = strtotime("2013-1-1"); //New Year's Day 2013
- $sub1 = ceil(($time2 - $ time1)/3600); //(60 seconds*60 minutes) seconds/hour
- $sub2 = ceil(($time3 - $time1)/86400); //(60 seconds*60 minutes*24 hours) seconds/day
- echo "There are still$sub1hours before the holiday!!!";
- echo "
";
- echo "There are stillOh! ";
- ?>
Copy code
Explanation: The format of the ceil() function is float ceil(float value), which is a rounding function. The smallest integer less than the parameter value. If there is a decimal part, round it up. It should be noted that the return type of this function is float, not integer.
|