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:
/Date(1288709830000)/
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 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
${formatDate(InceptionDate)}