• Aries-Belgium

    (@aries-belgium)


    Hi,

    I’m having a problem with displaying dates in the configured timezone in WP. I use wp_next_scheduled() to get the next scheduled timestamp for a specific cron. That works! But when I display it using:
    date(get_option('date_format') . " " . get_option('time_format'), $next_timestamp);
    I always get the GMT time and my timezone is GMT+1.

    How does WordPress use the timezone? And is there a unified date function that I can use to show a timestamp in a the configured timezone?

    Regards.

Viewing 1 replies (of 1 total)
  • graymerica

    (@graymerica)

    Add this to your functions.php in your theme or in your plugin

    date_default_timezone_set(get_option(‘timezone_string’));

    It will set your timezone to the correct string from your wordpress option.

Viewing 1 replies (of 1 total)
  • The topic ‘Display dates in configured timezone’ is closed to new replies.