Use current_time(), not date_default_timezone_set()

Use WordPress’s

current_time( 'timestamp' )

if you need to get a time that’s adjusted for the site’s timezone setting in the admin area.

If you need to work with the timezone offset:

get_option( 'gmt_offset' )

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. WordPress.com Stats and other features are dependent on this, and will break in wild ways if you adjust the timezone.

Ready to get started?

Tell us about your needs

Let us lead the way. We’ll help you select a top tier development partner. We’ll train your developers, operations, infrastructure, and editorial teams. We’ll coarchitect your deployment processes. We will provide live support for peak events. We’ll help your people avoid dark alleys and blind corners, and reduce wasted cycles.