Title: Obtaining a local time
Author: WordPress VIP Documentation
Published: May 6, 2021
Last modified: March 7, 2024

---

 1. [WordPress on VIP](https://docs.wpvip.com/wordpress-on-vip/)
 2. Obtaining a local time

#  Obtaining a local time

To retrieve the current time as an object with the timezone from the WordPress Admin
settings, use the [`current_datetime()` function](http://developer.wordpress.org/reference/functions/current_datetime/).

To work with the timezone offset, the PHP [DateTimeZone](https://www.php.net/datetimezone)
object should be used with `[wp_date()](http://developer.wordpress.org/reference/functions/wp_date/)`.

    ```lang-php
    // usage example of DateTimeZone() and wp_date()
    $timezone = new DateTimeZone( 'Asia/Singapore' );
    wp_date("d-m-Y H:i:s", null, $timezone );
    ```

Do not use `date_default_timezone_set()`. WordPress Core requires the timezone in
PHP to be GMT+0, and several dependent features will break if the timezone is adjusted.

`current_time( 'timestamp' )` is no longer recommended since WordPress 5.3.

For more in-depth guidance on working with timezones, refer to the well-written 
[Make WordPress Core post: “Date/Time improvements.”](https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/)

Last updated: March 07, 2024