killerbng icon

Time Function - With Example

killerbng | PRO | 05/27/15 08:45:57 PM UTC | 0 ⭐ | 447 👁️ | Never ⏰ | []
PHP |

560 B

|

None

|

0 👍

/

0 👎

<?php
$timezones = array("America/New_York", "Australia/Victoria", "Europe/Moscow", "Europe/Kiev", "Brazil/East");
function get_time($tz){
    $date = new DateTime('now', new DateTimeZone($tz));
    return $date->format('d-m-Y H:i:s');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Time Zone Info</title>
<style>
    body{background:#CCC;}
</style>
<meta http-equiv="refresh" content="10;url=times.php">
</head>
<body>
<?php
foreach($timezones as $zone){
    $dt = get_time($zone);
    echo "<p><strong>".$zone."</strong> - ".$dt."</p>".PHP_EOL;
}
?>
</body>
</html>

Comments