Home Forums General Issues Update Site Timezone with ACF Field


Update Site Timezone with ACF Field

  • I’m building a custom options / setup page so a client can update various site settings (and a bunch of other stuff) rather than going to WP General Settings page.

    I’ve got basic text fields squared away such as Site Title, Site Tagline, etc. but I want to change the site Timezone. A few items:

    1. In creating a Select / dropdown field, How do I match the exact values that are available in the WP Settings page? (I cannot find a full list of existing timezones) For example, “Los Angeles” in the admin front end is saved as ‘America/Los_Angeles’ in the database.

    2. Once that is setup, how do I write the value back to the WP OPtions. I’ve tried

    update_option('timezone_string',get_field('platform_timezone','options'), true);

    But that doesn’t work. Any thoughts?


  • If you’re looking to reverse-engineer Core functionality, just look it up in the source code:

    wp_timezone_choice() generates the select options. You’ll likely need to create a custom way to parse this into your ACF select though.

    As for saving the field, the original option value should do. That’s what the WP options page does at least.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.