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

I have a custom MySQL table with two columns that look like this: `timestamp_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `datetime_created` DATETIME DEFAULT CURRENT_TIMESTAMP, When retrieving these values using $wpdb, I would like to know in what timezone the result will be, and whether I can have the result be in UTC: $row = $wpdb->get_row(“SELECT * FROM `test`”, … Read more

Timezone Settings: “UTC” and “local” times are incorrect

On the “General Settings” page of my WordPress site, it’s not displaying the correct UTC and local times (see screenshot below). The displayed UTC and local times are wrong. It should say that local time is “15:52” I’m running WordPress 4.9.6 and PHP 7.0.30. The default timezone in my “php.ini” file is set correctly–when I … Read more

Is it safe to use ‘date_default_timezone_set’ in plugin file?

I am using a sitemaps plugin which in very complex ways sets the timezone of <lastmod> (i.e. last modified time) for posts to GMT. Temporarily, until the plugin developer fixes it, I need to enforce a custom timezone on the plugin. The simple and straightforward way that I’ve found is to add something like date_default_timezone_set( … Read more

Trigger a cron every 24h GMT -8

I’ like to run a cron every 24 hours at midnight PST ( = GMT -8 ) This is what I have if ( !wp_next_scheduled( ‘cron_hook’ ) ) { //reset on 00:00 PST ( GMT -8 ) == GMT +16 $timeoffset = strtotime(‘midnight’)+((24-8)*HOUR_IN_SECONDS); if($timeoffset < time()) $timeoffset+(24*HOUR_IN_SECONDS); wp_schedule_event($timeoffset, ‘daily’, ‘cron_hook’); } This sets a daily … Read more