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:
$event_startdate_raw = intval(get_field('start_date', false, false)) / 1000;
$event_startdate = new DateTime();
$event_startdate->setTimestamp($event_startdate_raw)
$event_startdate->setTimezone(new DateTimeZone(timezone_name_from_abbr('', get_option('gmt_offset') * 3600, 0)));
$event_startdate_jMY = $event_startdate->format('j M Y');
Could anyone tell me how to make the package dates appear independent of the timezone that the editor is located, but based on the WP general settings?