根据从UI中选择的时区在php中过滤日期

fla*_*ash 6 html javascript php user-interface timezone

我正在处理如下所示的php代码,其中具有air_date,当从UI选择不同时区时,我想更改

邮递区号:

$cols = array(
    'e.description_' . $opp_lang . ' as translation',
    's.air_date',  // This is the entry point of air_date and its been used everywhere. 
    'e.program_id',
); 
Run Code Online (Sandbox Code Playgroud)

我用于时区的逻辑:

function tz_translations( $lang = 'en' ) {
    $tz_translations = [
        'en' => [
            'PST' => [
                'label' => 'PT',
                'diff'  => 'subtract 3 hours',
            ],
            'EST' => [
                'label' => 'ET',
                'diff'  => 'subtract 0 hours',
            ],
        ],
        'fr' => [
            'HNP' => [
                'label' => 'HP',
                'diff'  => 'subtract 3 hours',
            ],
            'HNE' => [
                'label' => 'HE',
                'diff'  => 'subtract 0 hours',
            ],
        ],
    ];

    return $tz_translations[ $lang ];
}   
Run Code Online (Sandbox Code Playgroud)

UI (JS代码): 在此处输入图片说明

<ul id="js-timezone-picker">
   <?php foreach ( $tz_translations as $key => $tz ) :
      $tz_param = strtolower( $tz['label'] );
      $active = ( $current_tz === $key ) ? 'active' : '';
      ?>
   <li>
      <button id="<?php echo esc_attr( 'js-time-' . $tz_param ) ?>"
         class="<?php echo sanitize_html_class( $active ) ?>"
         data-timezone="<?php echo esc_attr( $tz_param ) ?>"><?php echo esc_html( $tz['label'] ) ?></button>
   </li>
   <?php endforeach; ?>
</ul>
Run Code Online (Sandbox Code Playgroud)

当选择了PT / ET时,将在检查时变为:

<button id="js-time-pt" class="" data-timezone="pt">PT</button>
<button id="js-time-et" class="" data-timezone="et">ET</button>
Run Code Online (Sandbox Code Playgroud)

问题陈述:

我想知道我应该对上面的php代码进行哪些更改,以便从UI / JS代码中选择不同的时区时,php代码中的air_date会根据时区自动更改。

Sou*_*nal 0

如果它只是一个转换并且您不需要其他服务器信息,您应该将所有数据传递到客户端(例如通过 json 格式),然后使用按钮触发一个 Javascript 函数来执行您的特定转换。但如果您需要更改 php 对象,则需要服务器请求(get、post 或 Ajax)。