vendredi 17 mai 2019

date_format() in php not returning the formatted date

the date_format function is not returning the formatted value of the variable but instead the current date only

I have tried different date variables and formats but to no avail. This is done in wordpress environment.

....

 <span class="some-css-class">
  <?php
   $eventDate = new DateTime(the_field('date_event'));
   //'event_date is the name of the date time field created for the post
   echo date_format($eventDate,'M'); 
  ?>
  </span>

....

I have tried different variables and number formats. Searched for wordpress environment specific solutions but none works. The result shows today's date being formatted instead of the given date.

The result shows the date of the event in non-formatted form and today's date in formatted form.

Thank you




Aucun commentaire:

Enregistrer un commentaire