How do I format Date/Time with jQuery Templates?

i've just started using jQuery Templates as my javascript template engine. My question is, how can i format a date (returned from a ASP.NET Json ActionResult) in the form:


I tried doing the following:

{{= $.format(new Date(parseInt(comment.DateCreated.substr(6))), 'd')}} 

Note the above uses the new jquery globalization plugin to add the $.format method. Also note that {{= comment.DateCreated }} is long hand for saying ${comment.DateCreated}.

I'd really appreciate it if you could help.


This does actually work. I was using the beta version hosted on the Microsoft CDN. If you download the latest version everything works as expected.

This is what I used

var formatDate = function (datetime) {
    var dateObj = new Date(parseInt(datetime.replace("/Date(", "").replace(")/", ""), 10));
    return dateObj.format("dd-MMM-yyyy"); //01-Jun-2001

And this in my JQuery Template


Need Your Help

Is there any way to make this function look nicer?


I need a logic that will extract a url from Apache log file:

Data has been changed when save a BufferedImage to JPG, but work PNG

java image jpeg bufferedimage save-image

I had a bufferedImage image with data {0; 24; 40; 0; 12; 28; 11; 37;....} and i saved it to a file with code: