Advent Calendar – WordPress, WPCron and the right Time

WordPress offers a pseudo-cronjob functionality, which allows the developer to execute scheduled events. For example, the whole Update Notification does it. In these so-called Scheduled Events you can define your own jobs. Thereby you should however pay attention to one important thing: time.

The wp-cron.php works outside the core and loads only the most important things and leaves all settings of WordPress open. In the Settings -> General set time zone is not included. wp-cron.php runs on UTC.

That means: Are we in the time zone of Berlin, the local time is UTC +1. Are we performing a scheduled event, it will always be one hour after the actual time we like to execute. To change this, we use the following function:

function get_offset_to_gmt_in_seconds() {

	$current_timezone_offset = get_option( 'gmt_offset' );
	$offset = $current_timezone_offset * 3600;

	return $offset;

Guest Post

This post is written by Thomas Herzog – and is a guest post on WP Engineer about WordPress.
Thank you very much from my part to Thomas. Please see his nice plugins on the official WordPress repository.
If you also like to have your interesting post published on our website, please let us know on our contact page. Of course we will appreciate your contribution!





One response to “Advent Calendar – WordPress, WPCron and the right Time”

  1. […] uns Jon Hicks einen Weg, Icons mittels einer Symbolschrift und Pseudoelementen zu implementieren. Auf WPEngineer lesen wir heute einen kleinen Codeschnipsel zur WordPress-internen […]