"; if (strpos($yourtzlist, ',' . $deficc . ',') !== false) { $ourtz=explode('<', explode('>', explode(',' . $deficc . ',', $yourtzlist)[1])[1])[0]; } else { $ourtz="''"; //date.timezone; // ($_SERVER['TZ'] ?? (file_get_contents('/etc/timezone') ?: file_get_contents('/etc/localtime'))) } $calsel=''; if (1 == 1) { $bundle=new ResourceBundle('','ICUDATA'); $cnames=[]; $calendars=$bundle->get('calendar'); foreach ($calendars as $n=>$v) { if ($calsel == '') { $calsel=""; } $calsel=str_replace("", "", $calsel); $cnames[]=$n; } } $locsel=''; $arrl=ResourceBundle::getLocales(''); for ($df=0; $df"; } $locsel=str_replace("", "", $locsel); } } $ctynames=" "; echo "PHP Intl Current Time via Locale and TimeZone and optional Calendar - RJM Programming - December, 2024 var ctynames=\"" . str_replace("\n","",$ctynames) . "\"; var canmakenothing=false, firstloc=''; function tzdef(inloc) { var inicc=inloc.replace(/\-/g,'_').split('_')[eval(-1 + inloc.replace(/\-/g,'_').split('_').length)]; var jnicc=inicc; var newtstuff='', newlstuff='', newts=0, newls=0, tvalis=''; if (ctynames.indexOf(\" value='\" + inicc + \"'>\") != -1) { jnicc=ctynames.split(\" value='\" + inicc + \"'>\")[1].split('<')[0]; } if (document.getElementById('timezone').value == '' && inicc.trim() != '' && inicc == inicc.toUpperCase() && eval('' + inicc.length) == 2) { var tzoh=document.getElementById('tzsel').innerHTML; var aftertopt=document.getElementById('toptone').outerHTML; var tzloh=document.getElementById('locsel').innerHTML; var afterlopt=document.getElementById('loptone').outerHTML; var tzs=tzoh.split(',' + inicc + ','); if (eval('' + tzs.length) > 1) { //document.getElementById('timezone').value=tzs[1].split('>')[1].split('<')[0]; tvalis=tzs[1].split('>')[1].split('<')[0]; newtstuff+=''; for (newts=1; newts')[1].split('<')[0] != tvalis) { newtstuff+=''; } } tzs=tzloh.split('_' + inicc + '\"'); if (eval('' + tzs.length) > 1) { newlstuff+=''; for (newls=1; newls')[1].split('<')[0] != inloc) { newlstuff+=''; } } } } if (tzoh.indexOf(aftertopt) != -1 && newtstuff != '') { document.getElementById('tzsel').innerHTML=aftertopt.replace(' id=', ' data-id=').replace(' value=\"', ' value=\" ').replace(' a Time', ' ' + jnicc + ' Time') + newtstuff + aftertopt + tzoh.split(aftertopt)[1]; } if (tzloh.indexOf(afterlopt) != -1 && newlstuff != '') { document.getElementById('locsel').innerHTML=afterlopt.replace(' id=', ' data-id=').replace(' value=\"', ' value=\" ').replace(' a Locale', ' ' + jnicc + ' Locale') + newlstuff + afterlopt + tzloh.split(afterlopt)[1]; } if (tvalis != '') { document.getElementById('timezone').value=tvalis; } document.getElementById('locsel').value=inloc; firstloc=inicc; canmakenothing=true; } if (document.getElementById('tzsel').value == ' ' && canmakenothing) { if (inicc != firstloc) { document.getElementById('tzsel').value=''; } } return inloc.replace(/\-/g,'_'); } "; if (isset($_GET['locale']) && isset($_GET['timezone']) && isset($_GET['calendar'])) { if (1 == 6) { $tz = reset(iterator_to_array(IntlTimeZone::createEnumeration(strtoupper(substr(urldecode($_GET['locale']),0,2))))); $formatter = IntlDateFormatter::create( urldecode($_GET['locale']), IntlDateFormatter::FULL, IntlDateFormatter::FULL, $tz, IntlDateFormatter::GREGORIAN ); //ini_set('intl.default_locale', urldecode($_GET['locale'])); //ini_set('date.timezone', urldecode($_GET['timezone'])); //$cal = IntlCalendar::createInstance(); $cal = IntlCalendar::createInstance($tz, '@calendar=' . urldecode($_GET['calendar'])); $cal->set(IntlCalendar::FIELD_MONTH, 0); // 1st month, 1st day ... 9th month, Ramadan $cal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 1); //1st day $cal->clear(IntlCalendar::FIELD_HOUR_OF_DAY); $cal->clear(IntlCalendar::FIELD_MINUTE); $cal->clear(IntlCalendar::FIELD_SECOND); $cal->clear(IntlCalendar::FIELD_MILLISECOND); echo "In this " . explode('-', urldecode($_GET['calendar']))[0] . " year, the first day of the year started/will start on:\n\t", $formatter->format($cal), "\n"; //Itʼs the formatterʼs timezone that is used: $formatter->setTimeZone(urldecode($_GET['timezone'])); echo "After changing timezone:\n\t", $formatter->format($cal), "\n"; } else { $DateTime = new DateTime(); $IntlDateFormatter = new IntlDateFormatter( urldecode($_GET['locale']) . '@calendar=' . urldecode($_GET['calendar']), IntlDateFormatter::FULL, IntlDateFormatter::FULL, urldecode($_GET['timezone']), IntlDateFormatter::TRADITIONAL); echo '

' . $IntlDateFormatter->format($DateTime) . '



'; echo "

Show Current Time


RJM Programming - December, 2024


As per (white background textboxes optional) ...




 " . $locsel . "
 " . $yourtzlist . "
 " . $calsel . "

"; } } else if (isset($_GET['locale']) && isset($_GET['timezone']) && !isset($_GET['calendar'])) { $fmt = datefmt_create( urldecode($_GET['locale']), IntlDateFormatter::FULL, IntlDateFormatter::FULL, urldecode($_GET['timezone']), IntlDateFormatter::GREGORIAN ); echo '

' . datefmt_format($fmt, time()) . '



'; echo "

Show Current Time


RJM Programming - December, 2024


As per (white background textboxes optional) ...




 " . $locsel . "
 " . $yourtzlist . "
 " . $calsel . "

"; } else if (isset($_POST['locale']) && isset($_POST['timezone']) && isset($_POST['calendar'])) { $DateTime = new DateTime(); $IntlDateFormatter = new IntlDateFormatter( urldecode($_POST['locale']) . '@calendar=' . urldecode($_POST['calendar']), IntlDateFormatter::FULL, IntlDateFormatter::FULL, urldecode($_POST['timezone']), IntlDateFormatter::TRADITIONAL); echo '

' . $IntlDateFormatter->format($DateTime) . '



'; echo "

Show Current Time


RJM Programming - December, 2024


As per (white background textboxes optional) ...




 " . $locsel . "
 " . $yourtzlist . "
 " . $calsel . "

"; } else if (isset($_POST['locale']) && isset($_POST['timezone']) && !isset($_POST['calendar'])) { $fmt = datefmt_create( urldecode($_POST['locale']), IntlDateFormatter::FULL, IntlDateFormatter::FULL, urldecode($_POST['timezone']), IntlDateFormatter::GREGORIAN ); echo '

' . datefmt_format($fmt, time()) . '



'; echo "

Show Current Time


RJM Programming - December, 2024


As per (white background textboxes optional) ...




 " . $locsel . "
 " . $yourtzlist . "
 " . $calsel . "

"; } else if (isset($_GET['test'])) { $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo '

First Formatted output is ' . datefmt_format($fmt, 0) . '


'; $fmt = datefmt_create( 'de-DE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo '

Second Formatted output is ' . datefmt_format($fmt, 0) . '


'; $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'MM/dd/yyyy' ); echo '

First Formatted output with pattern is ' . datefmt_format($fmt, 0) . '


'; $fmt = datefmt_create( 'de-DE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN, 'MM/dd/yyyy' ); echo "

Second Formatted output with pattern is " . datefmt_format($fmt, 0) . '


'; } else { echo "

Show Current Time


RJM Programming - December, 2024


As per (white background textboxes optional) ...




 " . $locsel . "
 " . $yourtzlist . "
 " . $calsel . "

"; } echo ""; ?>