Created
August 19, 2024 10:29
-
-
Save tranchausky/8e5f9bfc94d06ca547a4e2d5fd91e766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define the timezone identifier for California | |
$timezoneIdentifier = 'America/Los_Angeles'; | |
// Create a DateTimeZone object with the specified timezone | |
$timezone = new DateTimeZone($timezoneIdentifier); | |
// Get the timezone offset in seconds | |
$offset = $timezone->getOffset(new DateTime('now', $timezone)); | |
// Convert offset to hours | |
$offsetHours = $offset / 3600; | |
// Output timezone and offset | |
echo 'Timezone: ' . $timezoneIdentifier . PHP_EOL; | |
echo 'Offset: ' . $offsetHours . ' hours from UTC' . PHP_EOL; | |
//Timezone: America/Los_Angeles | |
//Offset: -7 hours from UTC | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment