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 ...
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 ...
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 ...
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 ...
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 ...
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('...
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)...
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" ) ) );
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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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:...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
timezones × 58date-time × 30
date × 13
timestamp × 13
php × 9
cron × 3
plugins × 2
posts × 2
custom-field × 2
mysql × 2
wp-cron × 2
server × 2
scheduled-posts × 2
plugin-development × 1
functions × 1
wp-query × 1
woocommerce-offtopic × 1
multisite × 1
wp-admin × 1
users × 1
post-meta × 1
comments × 1
login × 1
forms × 1
options × 1