JSFiddle - React, Tailwind, and code Playground
by rasikaceg
HTML
public static function addXmlDate($key, $value)
{
return VBTResponse::addXmlNodeWithAttributes($key, "",
array(DATE_VALUE => $value[DATE_VALUE], DATE_DAY => $value[DATE_DAY], DATE_DAYNAME => $value[DATE_DAYNAME], DATE_MONTH => $value[DATE_MONTH], DATE_MONTHNAME => $value[DATE_MONTHNAME],
DATE_YEAR => $value[DATE_YEAR], DATE_TIME12 => $value[DATE_TIME12], DATE_TIME24 => $value[DATE_TIME24], DATE_TMZ => $value[DATE_TMZ]));
}
CSS
public static function getDateArray()
{
return array (DATE_VALUE => "", DATE_DAY => "", DATE_DAYNAME => "", DATE_MONTH => "", DATE_MONTHNAME => "", DATE_YEAR => "", DATE_TIME12 => "", DATE_TIME24 => "", DATE_TMZ => "");
}
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
...