WPIntell

Source evidence

date picker box wrongly displays UTC

Content Scheduler · support · 2016-06-14T20:26:00+00:00

complaintsentiment
mediumseverity
0.87relevance
1replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 33 rows with source links

15.2% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
alien8 unresolved
I’ve determined that while the date/time data in the picker box is correct and correctly being adjusted for the timezone WordPress is currently set for, Content Scheduler only displays UTC after the values which can be a bit confusing. https://wordpress.org/plugins/content-scheduler/ Have had the same issue. There is a logical bug in the DateUtilities.php which is stored in the include subfolder. You have to change public static function getReadableDateFromTimestamp( $unixTimestamp ) { // get datetime object from unix timestamp try { $datetime = new DateTime( "@$unixTimestamp", new DateTimeZone( 'UTC' ) ); } catch (Exception $e) { return false; } // set the timezone to the site timezone $datetime->setTimezone( new DateTimeZone( DateUtilities::wp_get_timezone_string() ) ); date_default_timezone_set(DateUtilities::wp_get_timezone_string()); // return the unix timestamp adjusted to reflect the site's timezone // return $timestamp + $datetime->getOffset(); $localTimestamp = $unixTimestamp + $datetime->getOffset(); $blog_date_format = get_option( 'date_format' ); $blog_time_format = get_option( 'time_format' ); $dateString = date_i18n( $blog_date_format, $localTimestamp ); $timeString = date( $blog_time_format, $localTimestamp ); // put together and return return $dateString . " " . $timeString; } to public static function getReadableDateFromTimestamp( $unixTimestamp ) { $blog_date_format = get_option( 'date_format' ); $blog_time_format = get_option( 'time_format' ); $dateString = date_i18n( $blog_date_format, $unixTimestamp ); $timeString = date( $blog_time_format, $unixTimestamp ); // put together and return return $dateString . " " . $timeString; } If you use date or date_i18n the timestamp has to be UTC. But in the original code the local timestamp was used and therefore the offset is been added twice because of the function thinks the second param is in UTC. Note: date_i18n is a wordpress builtin function whether date is a builtin php function. I hope I could help you and for the plugin author apply my fix asap.

Comments

1 shown
mumbomedia 2016-11-09T10:20:00+00:00

Have had the same issue. There is a logical bug in the DateUtilities.php which is stored in the include subfolder. You have to change public static function getReadableDateFromTimestamp( $unixTimestamp ) { // get datetime object from unix timestamp try { $datetime = new DateTime( "@$unixTimestamp", new DateTimeZone( 'UTC' ) ); } catch (Exception $e) { return false; } // set the timezone to the site timezone $datetime->setTimezone( new DateTimeZone( DateUtilities::wp_get_timezone_string() ) ); date_default_timezone_set(DateUtilities::wp_get_timezone_string()); // return the unix timestamp adjusted to reflect the site's timezone // return $timestamp + $datetime->getOffset(); $localTimestamp = $unixTimestamp + $datetime->getOffset(); $blog_date_format = get_option( 'date_format' ); $blog_time_format = get_option( 'time_format' ); $dateString = date_i18n( $blog_date_format, $localTimestamp ); $timeString = date( $blog_time_format, $localTimestamp ); // put together and return return $dateString . " " . $timeString; } to public static function getReadableDateFromTimestamp( $unixTimestamp ) { $blog_date_format = get_option( 'date_format' ); $blog_time_format = get_option( 'time_format' ); $dateString = date_i18n( $blog_date_format, $unixTimestamp ); $timeString = date( $blog_time_format, $unixTimestamp ); // put together and return return $dateString . " " . $timeString; } If you use date or date_i18n the timestamp has to be UTC. But in the original code the local timestamp was used and therefore the offset is been added twice because of the function thinks the second param is in UTC. Note: date_i18n is a wordpress builtin function whether date is a builtin php function. I hope I could help you and for the plugin author apply my fix asap.