Hi, I’m new to using ACF and still learning PHP so please bear with me.
I’m helping to maintain a website where one of the custom fields is a package start date. The field type is date picker and the save format is “@” (which I believe means unix time).
The general wordpress settings are set to the timezone of most of the website editors (UTC+8) and when someone from this timezone enters a date of 25th for example, it appears correctly as 25th.
However when an editor from a further ahead timezone of UTC+10 enters a date it appears as one day earlier on the website. (If she enters 25th, it appears incorrectly as 24th). The issue can be fixed if someone from the “normal” UTC+8 timezone re-saves the package.
This is the code in the functions file to show the package time:
Using built in WP settings and functions you cannot do this.
It is especially difficult because you want this to work on the front end of the site and at this point there isn’t any way for PHP to know what editor set the time.
The best solution that I can think of is to add a new field where the editor can select a time zone, like a select field, and have the values of this field match the format of the default time zone setting in WP. Then use this new field value to replace get_option('gmt_offset')
You could limit the select field to only those values you need and have the default be where most of the editors are located.
Viewing 2 posts - 1 through 2 (of 2 total)
The topic ‘Date Picker – Output changes depending on editor timezone?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users