Reputation: 11
Is there a PHP(-MySQL) script (/class) that produces local time for a particular city of the world respecting DST changes.
Upvotes: 1
Views: 70
Reputation: 95424
You can create a DateTime
object representing the local time for any valid ISO-3166-1 timezone identifier.
$bigAppleTime = new DateTime("now", new DateTimeZone("America/New_York"));
echo "It is currently " . $bigAppleTime->format('r') . " in New York city";
You can get a list of valid identifiers and the current time at each by doing the following:
$timezones = DateTimeZone::listIdentifiers();
foreach($timezones as $zone) {
$time = new DateTime("now", new DateTimeZone($zone));
printf("% 35s: %s\n", $zone, $time->format('r'));
}
Upvotes: 2