I have come across a unique situation where I can no longer use php to format a timestamp and instead need to us jquery/js.
in php :
given ('2014-04-01 20:05:00', 'F jS, Y @ g:i a') would return 'April 1st, 2014 @ 8:05 pm'
// Date/time converter for strings
function convertStringTime($timestamp, $format)
{
if ($timestamp == '' or $timestamp == 0)
{
return 'n/a';
}
else // return actual time
{
$timestamp = strtotime($timestamp);
$timestamp = date($format, $timestamp);
return $timestamp;
}
}
I need to replicate this function in jquery/js with the same input and output. I did some quick searching, but cannot find any sorts of built-in calls to format date/time. Is there really nothing provided to do this?