AdvancedCustomFields / AdvancedCustomFields/acf

Fix date formatting

Open
#544 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hey there,

I'm having the issue that my date-time-picker field jumps back in time on each update of the post.
A solution I found that's working for me is to change the line 3879 in /includes/api/api-helpers.php (https://github.com/AdvancedCustomFields/acf/blob/master/includes/api/api-helpers.php#L3871):

// includes/api/api-helpers.php:3871
return wp_date($format, $unixtimestamp);

I also found this post by the WordPress core team:
https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/

Not recommended

  • don’t localize time based on WP timestamp:
    • date_i18n( DATE_RFC3339, $timestamp + $offset )

Recommended

  • localize time based on Unix timestamp:
    • wp_date( DATE_RFC3339, $timestamp )

Changing return date_i18n( $format, $unixtimestamp ); to return wp_date($format, $unixtimestamp); resolves the problem and is recommended by WordPress. Can this be fixed, please?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at includes/api/api-helpers.php around line 3871 and inspect the date-formatting call alongside the WordPress date-time guidance linked in the issue. Verify that the date-time-picker no longer jumps backward after a post update; no test file is named in the payload.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.