2
votes

I am struggling to get the date to output (at all!)

I have the following and I want the date to be output like 26th May 2014

            <p><?php the_field('description'); ?></p>
        <?php $date = DateTime::createFromFormat('Ymd', get_field('when')); ?>
        <h2><?php echo $date->format('d-m-Y'); ?></p>

All the above is inside a wordpress loop Even if I move the variable declaration outside the loop, it still doesn;t work.

thanks

1

1 Answers

0
votes

This will echo:

<?php the_date('jS F Y'); ?>

This will return the value to the $date var:

<?php $date = get_the_date('jS F Y'); ?>