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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.