I am working on a php code as shown below which has air_date which I want to be changed when different timezone is selected from UI.
Php code:
$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',
);
Logic I have used for timezone:
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 ];
}
<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>
When PT/ET is selected then it becomes the following on inspect:
<button id="js-time-pt" class="" data-timezone="pt">PT</button>
<button id="js-time-et" class="" data-timezone="et">ET</button>
Problem Statement:
I am wondering what changes I should make in the php code above so that when different time-zones is selected from the UI/JS code, air_date in the php code gets changed automatically in accordance with time-zones.
from filter dates in php in accordance with timezone selected from UI

No comments:
Post a Comment