芝麻web文件管理V1.00
编辑当前文件:/home/ezdajrnh/public_html/wp-content/plugins/google-listings-and-ads/src/Admin/Input/DateTime.php
get_value() ) ) { try { // Display the time in site's local timezone. $datetime = new WC_DateTime( $this->get_value(), new DateTimeZone( 'UTC' ) ); $datetime->setTimezone( new DateTimeZone( $this->get_local_tz_string() ) ); $view_data['value'] = $datetime->format( 'Y-m-d H:i:s' ); $view_data['date'] = $datetime->format( 'Y-m-d' ); $view_data['time'] = $datetime->format( 'H:i' ); } catch ( Exception $e ) { do_action( 'woocommerce_gla_exception', $e, __METHOD__ ); $view_data['value'] = ''; $view_data['date'] = ''; $view_data['time'] = ''; } } return $view_data; } /** * Set the form's data. * * @param mixed $data * * @return void */ public function set_data( $data ): void { if ( is_array( $data ) ) { if ( ! empty( $data['date'] ) ) { $date = $data['date'] ?? ''; $time = $data['time'] ?? ''; $data = sprintf( '%s%s', $date, $time ); } else { $data = ''; } } if ( ! empty( $data ) ) { try { // Store the time in UTC. $datetime = new WC_DateTime( $data, new DateTimeZone( $this->get_local_tz_string() ) ); $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); $data = (string) $datetime; } catch ( Exception $e ) { do_action( 'woocommerce_gla_exception', $e, __METHOD__ ); $data = ''; } } parent::set_data( $data ); } /** * Get site's local timezone string from WordPress settings. * * @return string */ protected function get_local_tz_string(): string { return wp_timezone_string(); } }