2024-09-13 09:13:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// get the UTC offset of a specified timezone
|
|
|
|
function getUTCOffset($timezone) {
|
2024-09-13 10:04:15 +00:00
|
|
|
$formattedOffset = '';
|
|
|
|
if (isset($timezone)) {
|
2024-09-13 09:13:00 +00:00
|
|
|
|
2024-09-13 10:04:15 +00:00
|
|
|
$datetime = new DateTime("now", new DateTimeZone($timezone));
|
|
|
|
$offsetInSeconds = $datetime->getOffset();
|
|
|
|
|
|
|
|
$hours = intdiv($offsetInSeconds, 3600);
|
|
|
|
$minutes = ($offsetInSeconds % 3600) / 60;
|
|
|
|
$formattedOffset = sprintf("UTC%+03d:%02d", $hours, $minutes); // Format UTC+01:00
|
|
|
|
}
|
2024-09-13 09:13:00 +00:00
|
|
|
|
|
|
|
return $formattedOffset;
|
2024-09-13 10:04:15 +00:00
|
|
|
|
2024-09-13 09:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|