Title: Uncaught Exception: DateTime::__construct(): Failed to parse time string
Last modified: July 14, 2020

---

# Uncaught Exception: DateTime::__construct(): Failed to parse time string

 *  Resolved [Deepak Chauhan](https://wordpress.org/support/users/deepchauhan/)
 * (@deepchauhan)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/)
 * Hi,
    I am getting an error when I add this code to get the event month. Please
   help me how I can resolve this issue. Error is : Uncaught Exception: DateTime::
   __construct(): Failed to parse time string (23/07/2020) at position 0 (2):
 * Code Which I am using :
 *     ```
       <?php
         eventDate = new DateTime(get_field('event_date'));
         echo $eventDate->format('M')
       ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Deepak Chauhan](https://wordpress.org/support/users/deepchauhan/)
 * (@deepchauhan)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/#post-13129405)
 * Hi,
    I have fixed the issue just add this code below.
 *     ```
       // get raw date
       $date = get_field('event_date', false, false);
       // make date object
       $date = new DateTime($date);
       echo $date->format('M');
       ```
   
 * I hope this will help you all.
 * Thank You
 *  [deepakg](https://wordpress.org/support/users/deepakg/)
 * (@deepakg)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/#post-13458209)
 * Thanks bro this code helped me.
 *  [rikorebel](https://wordpress.org/support/users/rikorebel/)
 * (@rikorebel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/#post-13810705)
 * Thank you bro, you was very useful
 *  [cupidanish10](https://wordpress.org/support/users/cupidanish10/)
 * (@cupidanish10)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/#post-14511076)
 * Hi can anyone explain the code why this was not working. Is it work for 1 day?
   
   I mean i added 2 posts yesterday and this code was working fine. But today I 
   added new and this is not working. <?php eventDate = new DateTime(get_field(‘
   event_date’)); echo $eventDate->format(‘M’) ?>
 * and this is working fine how?
    // get raw date $date = get_field(‘event_date’,
   false, false); // make date object $date = new DateTime($date); echo $date->format(‘
   M’);`

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Uncaught Exception: DateTime::__construct(): Failed to parse time string’
is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [Advance Custom Field](https://wordpress.org/support/topic-tag/advance-custom-field/)
 * [date format](https://wordpress.org/support/topic-tag/date-format/)
 * [uncaught exception](https://wordpress.org/support/topic-tag/uncaught-exception/)

 * 4 replies
 * 4 participants
 * Last reply from: [cupidanish10](https://wordpress.org/support/users/cupidanish10/)
 * Last activity: [4 years, 12 months ago](https://wordpress.org/support/topic/uncaught-exception-datetime__construct-failed-to-parse-time-string/#post-14511076)
 * Status: resolved