如何使用jQuery模板格式化日期/时间?

nfp*_*lee 11 asp.net-mvc jquery jquery-templates

我刚开始使用jQuery模板作为我的javascript模板引擎.我的问题是,我如何格式化日期(从ASP.NET Json ActionResult返回)格式:

/Date(1288709830000)/
Run Code Online (Sandbox Code Playgroud)

我尝试过以下操作:

{{= $.format(new Date(parseInt(comment.DateCreated.substr(6))), 'd')}} 
Run Code Online (Sandbox Code Playgroud)

注意上面使用新的jquery全球化插件来添加$.format方法.还要注意说{{= comment.DateCreated }}是长话${comment.DateCreated}.

如果你能提供帮助,我真的很感激.

nfp*_*lee 2

这确实有效。我使用的是 Microsoft CDN 上托管的测试版。如果您下载最新版本,一切都会按预期运行。