AlexKondov

Time Until New year

Aug 15th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Time Until New Year</title>
  6. </head>
  7. <body>
  8.     <?php
  9.         $now = time(); // or your date as well
  10.         $your_date = strtotime("2014-12-31");
  11.         $datediff = $your_date-$now;
  12.  
  13.         $date = date('h:i:s a', time());
  14.         $arr = explode(":", $date);
  15.        
  16.         $days = floor($datediff/(60*60*24));
  17.         $hours = (floor($datediff/(60*60*24)) * 24) - (int)($arr[0]);
  18.         echo "Hours: $hours <br>";
  19.         $minutes = ((floor($datediff/(60*60*24)) * 24) * 60) - (int)($arr[1]);
  20.         echo "Minutes: $minutes <br>";
  21.         $seconds = (((floor($datediff/(60*60*24)) * 24) * 60) * 60) - (int)($arr[2]);
  22.         echo "Seconds: $seconds <br>";
  23.  
  24.         echo "Days:Hours:Minutes:Seconds $days:" . $hours % 24 . ":" . $minutes % 60 . ":" . $seconds % 60 . "<br>";    
  25.     ?>
  26.     </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment