我正在使用 jQuery 模板,并且想做一个时间戳比较。这可能吗?
我希望按照以下方式做一些事情:
<script id='mytemplate' type='text/html'>
{{if 2011-03-02T14:15:04-08:00 > Current_timestamp}}
New
{{else}}
not new
{{/if}}
</script>
可能的?谢谢
更新,实现客户端时间不起作用,需要通过当前服务器时间:这是最新的:
<script id="comment" type="text/html">
{{if new Date(cmtModel.conv_last_reply()) > new Date(created_at) }}
yep
{{else}}
nope
{{/if}}
</script>
cmtModel.conv_last_reply() 来自 KnockoutJS,created_at 是创建评论的时间。