Home Forums Backend Issues (wp-admin) Date time picker does not allow time to be output before date


Date time picker does not allow time to be output before date

  • Hi,

    I’m trying to output and ACF field as H.i j F Y, however the Date Time picker field displays:

    “08.00 j F Y”

    I’ve had a look at the code behind this and the code assumes the date will always be before the time:

    		// if index found
    		if( $index !== false ) {
    			$data['date'] = trim(substr($date_time, 0, $i));
    			$data['time'] = trim(substr($date_time, $i));
    		// return
    		return $data;	

    Line 141 – date_time_picker.php

  • Have you tried converting the string to a Unix timestamp?

    $date_time = get_field('date_time');
    echo date("H.i j F Y", strtotime($date_time);
  • Hi @gmsb

    I’ve just tested it on my end and it was working as it should. Could you please tell me how did you change the format and show the date time field?

    Thanks 🙂

  • @neioo Thanks for the suggestion, I’m using DateTime createFromFormat at the moment to output the date on the frontend but I’d quite like to configure the backend to show the date in the same format.

    @james Hi James, thank you for testing it your end, I’ve attached an export file of a field where the issue is occurring. (I’m using the ACF 4.5.0 beta at the moment as I needed to use the Google Maps field).

    The attached field in a nutshell:
    Date Time Picker field
    Display format: H.i j F Y
    Return format: H.i j F Y

    When editing a post this returns: 12.30 j F Y
    It should return 12.30 1 July 2016

  • Here’s a screenshot of what is output on the edit posts page:

  • This reply has been marked as private.
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.