0

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?

1
  • datejs.com Commented Apr 16, 2014 at 3:13

1 Answer 1

1

jQuery dateFormat is a separate plugin. You need to load that explicitly using a <script> tag. Directly you do not have any option.

Sign up to request clarification or add additional context in comments.

1 Comment

nice find... this works great... thanks for the recommendation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.