Title: WordPress wrong dates bug
Last modified: August 18, 2020

---

# WordPress wrong dates bug

 *  [tanjar](https://wordpress.org/support/users/tanjar/)
 * (@tanjar)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/wordpress-wrong-dates-bug/)
 * I am using WordPress version 5.4.
 * I have a problem with the dates in a CPT, and it is that the dates show one day
   less.
 * Example: If I put in the backend the date, 08/18/20, in the frontend it shows
   me 08/17/20
 * I think for some reason the date_i18n function is not executing correctly.
 * This is the code where I show the dates:
 * `<time><?php if (isset($event_from_date) && $event_from_date <> ”) echo date_i18n(
   get_option(‘date_format’), strtotime($event_from_date)) . ‘,’; ?></time>

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

 *  [Mangesh Nadekar](https://wordpress.org/support/users/mangeshnadekar15/)
 * (@mangeshnadekar15)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/wordpress-wrong-dates-bug/#post-13276751)
 * Hi [@tanjar](https://wordpress.org/support/users/tanjar/),
 * Replace your code
 * `<time><?php if (isset($event_from_date) && $event_from_date <> ”) echo date_i18n(
   get_option(‘date_format’), strtotime($event_from_date)) . ‘,’; ?></time>`
 * with
 *     ```
       <time>
       <?php
       // your_meta_key replace with post meta key
       $event_from_date = get_post_meta( $post->ID, 'your_meta_key', true );
   
       if ( isset( $event_from_date ) && !empty( $event_from_date ) ) {
       	echo date_i18n(get_option('date_format'), strtotime( $event_from_date ));
       }
       ?>
       </time>
       ```
   
 * I checked date_i18n() and it is working fine for me
 *     ```
       <time>
       <?php
       $event_from_date = time();
   
       if ( isset( $event_from_date ) && !empty( $event_from_date ) ) {
        echo date_i18n(get_option('date_format'), strtotime( $event_from_date ));
       }
       ?>
       </time>
       ```
   
 * [check: time()](https://www.php.net/manual/en/function.time.php)
    -  This reply was modified 5 years, 10 months ago by [Mangesh Nadekar](https://wordpress.org/support/users/mangeshnadekar15/).
    -  This reply was modified 5 years, 10 months ago by [Mangesh Nadekar](https://wordpress.org/support/users/mangeshnadekar15/).
 *  Thread Starter [tanjar](https://wordpress.org/support/users/tanjar/)
 * (@tanjar)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/wordpress-wrong-dates-bug/#post-13277008)
 * Hi [@mangeshnadekar15](https://wordpress.org/support/users/mangeshnadekar15/)
   Thanks for you reply.
 * The code you recommend is the same as the one I already have.
 * The date_i18n function is not doing the job, instead if I change it to date ()
   it shows the correct dates, but not the required language
 *  [Mangesh Nadekar](https://wordpress.org/support/users/mangeshnadekar15/)
 * (@mangeshnadekar15)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/wordpress-wrong-dates-bug/#post-13280550)
 * Hi [@tanjar](https://wordpress.org/support/users/tanjar/),
 * Yes, we can use date() function, also WordPress date_i18n() function is giving
   me same result just like PHP date() function.

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

The topic ‘WordPress wrong dates bug’ is closed to new replies.

## Tags

 * [dates](https://wordpress.org/support/topic-tag/dates/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Mangesh Nadekar](https://wordpress.org/support/users/mangeshnadekar15/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/wordpress-wrong-dates-bug/#post-13280550)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
