Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘date picker box wrongly displays UTC’ is closed to new replies.