Use current_datetime(), not date_default_timezone_set()

If you need to get a time that’s adjusted for the site’s timezone setting in the admin area, use:

current_datetime()

 

If you need to work with the timezone offset, consider using the PHP DateTimeZone object with wp_date()

$timezone = new DateTimeZone( 'Asia/Singapore' );
wp_date("d-m-Y H:i:s", null, $timezone );

 

Please don’t use date_default_timezone_set(). The timezone in PHP needs to stay GMT+0 as that’s what WordPress expects it to be. Several features are dependent on this, and will break if you adjust the timezone.

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

For more tips on timezones, visit the excellent Date/Time improvements post!

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.