Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Time Until New Year</title>
- </head>
- <body>
- <?php
- $now = time(); // or your date as well
- $your_date = strtotime("2014-12-31");
- $datediff = $your_date-$now;
- $date = date('h:i:s a', time());
- $arr = explode(":", $date);
- $days = floor($datediff/(60*60*24));
- $hours = (floor($datediff/(60*60*24)) * 24) - (int)($arr[0]);
- echo "Hours: $hours <br>";
- $minutes = ((floor($datediff/(60*60*24)) * 24) * 60) - (int)($arr[1]);
- echo "Minutes: $minutes <br>";
- $seconds = (((floor($datediff/(60*60*24)) * 24) * 60) * 60) - (int)($arr[2]);
- echo "Seconds: $seconds <br>";
- echo "Days:Hours:Minutes:Seconds $days:" . $hours % 24 . ":" . $minutes % 60 . ":" . $seconds % 60 . "<br>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment