Title: $time-&gt;format() displays wrong date
Last modified: August 30, 2016

---

# $time->format() displays wrong date

 *  Resolved [resting](https://wordpress.org/support/users/resting/)
 * (@resting)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-format-displays-wrong-date/)
 * I believe its due to timezone issue.
    The server is set to UTC, and software 
   local timezone is set to Asia/Singapore (UTC +8). After the line `$time = $this-
   >_registry->get( 'date.time' );` in `widget.php` I trie `$time->format()` to 
   get the current time and got a time that is -8 of local time. Is there anyway
   to get it to return the local time instead of server time?
 * Have also tried to set date manually with timezone,
 *  $time =$time->set_date_time(‘now’, ‘Asia/Singapore’);
    $time->format()
 * but its still -8 behind local time.
 * [https://wordpress.org/plugins/all-in-one-event-calendar/](https://wordpress.org/plugins/all-in-one-event-calendar/)

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

 *  [Benjamin](https://wordpress.org/support/users/bsokic/)
 * (@bsokic)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-format-displays-wrong-date/#post-6720732)
 * Hi,
 * “Display events in calendar time zone” option should help, go to Events > Settings
   > Display events in calendar time zone, and select the option.
 *  Thread Starter [resting](https://wordpress.org/support/users/resting/)
 * (@resting)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-format-displays-wrong-date/#post-6720886)
 * Hi,
 * Thanks for the suggestion, I’d checked the option, but it didn’t work.
    There’s
   a line in `widget.php` which is
 *     ```
       // Get localized time
           $timestamp = $time->format_to_gmt();
       ```
   
 * right after that I tried printing the `$timestamp` and it still shows -8 time.
 * Maybe format_to_gmt is causing it to ignore timezone so I tried,
 *     ```
       $timestamp = $time->format();
       ```
   
 * But it shows the same time as `format_to_gmt()`
 * This is causing problems in the widget when I set it to 1 day’s event. That is,
   I only want to show today’s events. But due to the timestamp offset, it may or
   may not show events that’s supposed to start the next day.

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

The topic ‘$time->format() displays wrong date’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/all-in-one-event-calendar.svg)
 * [Timely All-in-One Events Calendar](https://wordpress.org/plugins/all-in-one-event-calendar/)
 * [Support Threads](https://wordpress.org/support/plugin/all-in-one-event-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/all-in-one-event-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/all-in-one-event-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/all-in-one-event-calendar/reviews/)

## Tags

 * [local](https://wordpress.org/support/topic-tag/local/)
 * [server](https://wordpress.org/support/topic-tag/server/)
 * [time](https://wordpress.org/support/topic-tag/time/)
 * [timezone](https://wordpress.org/support/topic-tag/timezone/)

 * 2 replies
 * 2 participants
 * Last reply from: [resting](https://wordpress.org/support/users/resting/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/time-format-displays-wrong-date/#post-6720886)
 * Status: resolved