Support

Account

Home Forums Front-end Issues Date format is wrong Reply To: Date format is wrong

  • rockeypjb thanks for that direction above. I have selected an ACF date though when uploading an article in the post admin so shouldn’t it then print in the format I have selected in the display settings?

    Using your suggestion above if I enter that as is without changing the filedname I see it prints the current date. I add in my own field name and it stops printing the page at that point (I’ve changed the date format).

    <?php $date = new DateTime(get_field(‘published_on’));
    echo $date->format(‘d/m/Y’); ?>

    What I ideally want is something like the below (but this doesn’t work)

    <span>Published on:</span>
    <?php $published_on = get_field(‘published_on’);
    if ($published_on) {
    echo $published_on->format(‘d/m/Y’);
    } else {
    echo ‘Not known’;
    } ?>

    Is there something simple I’m doing wrong here?