Support » Plugins » How to convert GMT time to user-set Timezone

  • I am having a heck of a time doing something that I feel should be so simple in a plugin.

    I have a date/time in GMT and I want to convert it to a date/time in the timezone the blog owner has selected in settings. But I can’t find anything to do it.

    I would expect date_i18n to do it, but it doesn’t.

    I’m using wordpress 2.9.1 and when I call date_default_timezone_get() it returns ‘UTC’ even though I have my timezone in settings as ‘America/Los_Angeles’.

    My current solution is going to be to create a function to do this:

    $timezone = date_default_timezone_get();
    date_default_timezone_set(get_option('timezone_string'));
    
    // do date conversion
    
    date_default_timezone_set($timezone);

    I have searched and read and looked at bugs and applied fixes to my local wordpress code and really done my due diligence here, but if through all that I have missed the obvious, please let me know the right thing to do.

    Thanks,
    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to convert GMT time to user-set Timezone’ is closed to new replies.