Home Forums ACF PRO ACF Pro Dates Showing Jan 1 1970 Reply To: ACF Pro Dates Showing Jan 1 1970

  • Hi @mpayumo

    I think there’s something wrong with the formatting. Could you please let me know the value of your Return Format option?

    But you can also set the formatting to false in your code so that you will get a consistent output. Here’s an example for this case:

    // get the raw value
    $event_date = get_sub_field('event_date', false, false);
    // convert it to a date object
    $event_date = date_create_from_format( 'Ymd', $event_date );
    // set the format
    $first_date = $event_date->format('F j');
    $new_time = $event_date->format('ga');
    $last_date = $event_date->format('j');
    $last_date_compare = $event_date->format('F j');
    // show it
    echo $first_date . ' - ' . $last_date;;

    I hope this helps 🙂