min/max timezone not work
-
I’m not an English speaker, so please forgive me if there are some improper parts.
The time zone is used at’+9:00′.
When the current time (WP server) time is from 0:00 to 9:00,’Minimum Date’ is not processed correctly.Example)
timezone ‘+9:00’
Current date: 2021-01-25 Hours 0:00-9:00
‘Minimum Date’ setting: “+5 days”
Date picker UI 2021-01-29 However, after 9:00, it will be 2021-01-30.In Minimum Date and Maximum Date, the time zone is not processed properly when the format is relative.
https://github.com/carmoreira/date-time-picker-field/blob/master/includes/DateTimePicker.php
public function set_rules()
143行目
$temp_date = strtotime( $opts['max_date'] );
Timezone cannot be processed with strtotime.
I want you to replace it with the one that uses the time zone of DateTime or date_create ()./*2021.01 ADD get $tzone*/ $tzone = get_option( 'timezone_string' ); if ( isset( $opts['datepicker'] ) && 1 === intval( $opts['datepicker'] ) ) { $format .= $opts['dateformat']; $clean_format .= $this->format( $opts['dateformat'] ); // max date. if ( isset( $opts['max_date'] ) && $opts['max_date'] !== '' ) { /*2021.01 Edit set $tzone $temp_date = strtotime( $opts['max_date'] );*/ $temp_date = date_create($opts['max_date'], new DateTimeZone( $tzone ) ); if ( $temp_date ) { //$opts['max_date'] = date( $clean_format, $temp_date ); $opts['max_date'] = $temp_date->format($clean_format); //$opts['max_year'] = date( 'Y', $temp_date ); $opts['max_year'] = $temp_date->format('Y'); } } // min date. if ( isset( $opts['min_date'] ) && $opts['min_date'] !== '' ) { /*2021.01 Edit set $tzone $temp_date = strtotime( $opts['min_date'] );*/ $temp_date = date_create($opts['min_date'], new DateTimeZone( $tzone ) ); if ( $temp_date ) { //$opts['min_date'] = date( $clean_format, $temp_date ); $opts['min_date'] = $temp_date->format($clean_format); //$opts['min_year'] = date( 'Y', $temp_date ); $opts['min_year'] = $temp_date->format('Y'); } else { $opts['min_date'] = false; } } }
- The topic ‘min/max timezone not work’ is closed to new replies.