JSFiddle - React, Tailwind, and code Playground
by rasikaceg
JavaScript
public static function getDateFromUNIX($timestamp, $tmz, $showtime)
{
$locArray = VBTResponse::getDateArray();
if ( $timestamp != FALSE )
{
$language = getGET(VBT_QRY_LANGUAGE);
$dateFmtAry = VBTLocalization::getDategetVBTDateFromUNIXFmtAry($language);
// Send string based on type of date format requested, I have tested if locale is not supported, the functions default to en-US
$locale = getGET(VBT_QRY_LANGUAGE).'-'.getGET(VBT_QRY_COUNTRY);
if ( $showtime )
{
// If 24 hour format requested, use it, else default to 12 hour format
if ( "24" === getGET(VBT_QRY_HOURFMT) )
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, $dateFmtAry['datetime24']);
else
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, $dateFmtAry['datetime12']);
$locArray[DATE_VALUE] = datefmt_format($fmtObj, $timestamp).' '.$tmz;
if($locArray[DATE_VALUE])
{
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, $dateFmtAry['time12']);
$locArray[DATE_TIME12] = datefmt_format($fmtObj, $timestamp);
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, $dateFmtAry['time24']);
$locArray[DATE_TIME24] = datefmt_format($fmtObj, $timestamp);
$locArray[DATE_TMZ] = $tmz;
}
}
else
{
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, $dateFmtAry['date']);
$locArray[DATE_VALUE] = datefmt_format($fmtObj, $timestamp);
}
// If we got a valid date, and were able to create some international date information, populate rest of structure
if($locArray[DATE_VALUE])
{
$fmtObj = datefmt_create($locale, IntlDateFormatter::LONG, IntlDateFormatter::SHORT, "GMT".$tmz, null, 'EEEE'); // Day name
...