Skip to main content
26 votes

How to get WordPress Time Zone setting?

The unfortunate situation is that there are indeed two different options: Newer timezone_string, which saves PHP–style time zone. Older gmt_offset, which saves numeric float offset in hours. But in ...
Rarst's user avatar
  • 99.9k
8 votes

PHP function showing wrong time in WordPress

date() is a PHP function depending on your server settings. You can go around that by using the WordPress function: current_time( 'Y-m-d H:i:s' ); This function takes the settings in wp-admin into ...
fischi's user avatar
  • 7,559
5 votes
Accepted

Immediately published posts are scheduled and published 2 hours later

The solution was to apt-get remove tzdata apt-get install tzdata while dpkg-reconfigure tzdata was not enough. Mark's edit: In human words, the problem was caused because the time zone data on ...
christophrus's user avatar
5 votes
Accepted

Date, Time, and Timezones

What is the purpose of the timezone setting in the Admin -> Settings section? Since WordPress handles time zone on its own (separately from native PHP functionality) that is where the setting made ...
Rarst's user avatar
  • 99.9k
3 votes
Accepted

Timezone is wrong when picking city (Copenhagen)

... why the timezone is set to UTC instead of what the value I've set in the WordPress-settings-page WordPress calculates offsets from UTC, therefore WordPress sets the default time zone to UTC and ...
Sally CJ's user avatar
  • 39.9k
3 votes

How to get WordPress Time Zone setting?

Given the fact that wordpress keeps the timezone string in the options table, you can use the object oriented way of getting the right time on your wordpress site: $tz = new DateTimeZone(get_option('...
Pål Bergquist's user avatar
3 votes

How to convert DateTime() to display time based on WordPress timezone setting?

I had developed a method in my lib to retrieve current WP’s time zone as proper object: WpDateTimeZone::getWpTimezone(). While timezone_string is straightforward (it is already a valid time zone name)...
Rarst's user avatar
  • 99.9k
2 votes
Accepted

Translate current_time

Used date_i18n instead of current_time. For example: echo date_i18n( 'Y. F j.', strtotime( get_the_time( "Y-m-d" ) ) );
Demyd Ganenko's user avatar
2 votes
Accepted

Display time as "12:00 noon" instead of "12:00 pm"

So what you need to do is make your life easier and instead of searching everything within every instance of .pp-post-content or .pp-post-content p, let's wrap the times or the times in question with ...
Tony Djukic's user avatar
  • 2,259
2 votes

Unknown or broken timezone error for America/Phoenix

When I began troubleshooting this issue, I viewed the lack of a value for gmt_offset as the culprit, and considered the server to be solid. But after I updated the gmt_offset value in the database and ...
chb's user avatar
  • 121
2 votes
Accepted

Is a MySQL DATETIME or TIMESTAMP value retrieved through $wpdb in UTC?

Summary: WordPress does run date_default_timezone_set( 'UTC' );. It does have a timezone option modifiable by the admins and retrieved using get_option( 'timezone_string' ). However, none of that has ...
Flimm's user avatar
  • 710
2 votes

Is there any way to get a drop down list of time zones?

Enter wp_timezone_choice(): <select> <?php echo wp_timezone_choice( 'UTC' ) ?> </select> Make sure to check out the documentation link, but the parameters are: $selected_zone (...
TheDeadMedic's user avatar
  • 36.6k
2 votes

Wordpress outputs mm/dd but it should be opposite

If it is the example in the timezone settings you're referring to here: Then this is expected behaviour, and is correct by definition according to ISO standards, because this is not the time, it's a ...
Tom J Nowell's user avatar
  • 60.6k
1 vote
Accepted

Why do I need to set my PHP timezone when it's already set in WordPress?

In functions.php if I add date_default_timezone_set( get_option('timezone_string') ); then $dt will output correctly with "PST". Yes, but, "don’t change PHP time zone with ...
Sally CJ's user avatar
  • 39.9k
1 vote

How to get User Time Zone in Wordpress?

Since WordPress is a server-side framework/CMS, it likely doesn't have the functionality you're looking for. If you're looking for ways to obtain this information, the most reliable would likely be to ...
Dylan Hildenbrand's user avatar
1 vote
Accepted

Getting wp_timezone undefined within a namespace

Thank you Tom J Nowell for the insightful comment above. Turns out that wp_timezone is a relatively recent addition to Wordpress, and didn't exist in the version of WP I was developing in. It was ...
MikeiLL's user avatar
  • 579
1 vote

Translate current_time

It may be worth looking at using something like date_i18n, which returns the date/time in a localised format https://codex.wordpress.org/Function_Reference/date_i18n To recreate the current_time ...
chrismou's user avatar
1 vote

Difference between date and date_gmt

The database is correct in this case. comment_date is the datetime of your WordPress timezone setting and comment_date_gmt is the same datetime, but converted to Greenwich Mean Time (GMT). GMT is the ...
MikeNGarrett's user avatar
  • 2,661
1 vote

Change wordpress current_time function to different timezone

current_time() supports GMT as the second parameter. See: https://codex.wordpress.org/current_time If no second parameter is passed it should return the timezone set for your site.
Jory Hogeveen's user avatar
1 vote

User specified Timezone

I this is an old thread but I too need user specific timezone setting. Here is a plugin that "WP User Level Timezone" will hopefully fit the needs of some looking for a user specific ...
Scott's user avatar
  • 11
1 vote

Is it safe to use 'date_default_timezone_set' in plugin file?

Currently, the built-in function current_time() expects function date_default_timezone_set() is never used. Inspecting the code of current_time() confirmed this, because that function formats the ...
Marco Marsala's user avatar
1 vote

How to get WordPress Time Zone setting?

Like Rarst said, you can now use wp_timezone() which returns a timezone object. Or to get the timezone as a string, wp_timezone_string(), which returns 'Europe/Rome', 'UTC', or the UTC offset like '-6:...
Brennan's user avatar
  • 201

Only top scored, non community-wiki answers of a minimum length are eligible