Support

Account

Forum Replies Created

  • I finally found a solution. When creating the custom fields, make sure you choose the Ymd return format. With other return formats, this does not work.

    Then in the code, get the field (or subfield, in my case): $date = get_sub_field('date');.

    Convert using PHP’s DateTime: $eventDate = new DateTime($date);

    And display using your required format, for example: $eventDate->format('j');

    Hope this helps!

  • I’m having the same issue. Depending on the solution I use on the forums, when trying to convert the date to a custom format I either see: (1) Jan 1 1970 as you’re seeing, or (2) the current date, which I have confirmed as it has changed as this problem is taking a while to research and resolve.

    Has anyone else found any solutions yet?

  • I’m having the same issue when using the date field in a repeater (the repeater is the subfield of a group).

    When I use the code $date = get_sub_field('date'); and echo the variable, the string returned matches the data entry in the database (each date is different). When I convert the date using methods above such as <?php echo date("F j, Y", strtotime($date)); ?>, the strtotime is not working and Jan 1, 1970 is always returned.

    In contrast, when I use the DateTime method mentioned above, only the current day’s date is returned.

    Is this a bug, should DateTime be avoided in repeaters?

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