jilo-web/app/helpers/profile.php

21 lines
500 B
PHP
Raw Normal View History

<?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 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
}
return $formattedOffset;
2024-09-13 10:04:15 +00:00
}
?>