user382538
user382538

Reputation:

display diffrent timezones time in a page with php?

how can i display diffrent timezones time in a page with php?

like

Eastern:    02:23 AM
Central:    02:23 AM
Asia/India: 02:23 AM
Mountain:   02:23 AM
Pacific:    02:23 AM

Upvotes: 1

Views: 1746

Answers (2)

xil3
xil3

Reputation: 16439

You can do something like this:

$date = new DateTime("now", new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName() . " - " . $date->format('H:m');

Upvotes: 2

Sjoerd
Sjoerd

Reputation: 75599

foreach (DateTimeZone::listIdentifiers() as $timezone)
{
    $time = new DateTime('now', new DateTimeZone($timezone));
    echo $timezone . ': ' . $time->format('c').'<br>';
}

Upvotes: 10

Related Questions