Skip to content

Datepicker, store_local_time and daylight saving #759

@petenelson

Description

@petenelson

We had an issue pop up recently when editing date/time in a custom field when the date and time happened after the 1hr change on daylight saving. The WordPress install is set to New York time, store_local_time is enabled. To replicate this, change the date/time of the event to anything after March 8, 2020 (the next time change), the hour gets reduced by one each time the post is saved (entered 2pm, saved it and it's 1pm, save it again and it's noon).

I was also able to replicate it when setting the date/time to prior to the recent 1hr time change (Nov 3rd). This seems to only happen when editing a time that falls outside the six-month window when there is no time change.

Some sample to drop into a dev site in order to replicate the issue.

<?php
/**
 * Plugin Name: Test Fieldmanager Time
 */

add_action( 'fm_post_post', 'test_fieldmanager_date_time' );

function test_fieldmanager_date_time() {

	$fields = [];

	$fields['start-time'] = new \Fieldmanager_Datepicker(
		[
			'label'            => __( 'Start Date/Time (Eastern)', 'stadium' ),
			'use_time'         => true,
			'store_local_time' => true,
			'default_value'    => current_time( 'timestamp', true ),
		]
	);

	$fm = new \Fieldmanager_Group(
		[
			'name'           => 'event-settings',
			'serialize_data' => false,
			'children'       => $fields,
		]
	);

	$fm->add_meta_box( 'Live Event Settings', [ 'post' ] );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions