Advertisement
killerbng

Time Function - With Example

May 27th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2. $timezones = array("America/New_York", "Australia/Victoria", "Europe/Moscow", "Europe/Kiev", "Brazil/East");
  3. function get_time($tz){
  4.     $date = new DateTime('now', new DateTimeZone($tz));
  5.     return $date->format('d-m-Y H:i:s');
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <title>Time Zone Info</title>
  12. <style>
  13.     body{background:#CCC;}
  14. </style>
  15. <meta http-equiv="refresh" content="10;url=times.php">
  16. </head>
  17. <body>
  18. <?php
  19. foreach($timezones as $zone){
  20.     $dt = get_time($zone);
  21.     echo "<p><strong>".$zone."</strong> - ".$dt."</p>".PHP_EOL;
  22. }
  23. ?>
  24. </body>
  25. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement