Search code examples
datetimejquery-templates

Formatting Date and Time in Jquery Template


Can you please tell me how to format date with time in jquery template like this:

11/9/2011 12:00:00 AM

I am using this function which only formats the date part and hide the time portion of it:

function (jsonDate) {
    var value = new Date(parseInt(jsonDate.substr(6)));
    return value.getMonth() + 1 + "/" + value.getDate() + "/" + value.getFullYear();
}

Solution

  • How about:

    function (jsonDate) {
        var value = new Date(parseInt(jsonDate.substr(6)));
        return value.toUTCString();
    }
    

    You can see more options here