6

I'm not perfect in PHP, I'm trying to show user's current timezone in wordpress site. User selected GMT Timezone is: UTC+5.30 but get_option('gmt_offset') returns '5.5'

How to get this '5.5' GMT offset as 'UTC+5.30' ?

1 Answer 1

3

Here is what I did:

$min    = 60 * get_option('gmt_offset');
$sign   = $min < 0 ? "-" : "+";
$absmin = abs($min);
$tz     = sprintf("UTC%s%02d:%02d", $sign, $absmin/60, $absmin%60);
0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.