I have the following time format:
我有以下时间格式:
Dec 29, 2016 10:57:58 PM
2016年12月29日下午10:57:58
How can I display it in a model of days ago. Like 10days or 20days using Freemarker?
如何在几天前的模型中显示它。喜欢使用Freemarker的10天或20天?
Thank you.
1 个解决方案
#1
0
FreeMarker templates don't do calendar calculations, or at least not unless you add a TemplateMethodModelEx
for them. But in principle such data should come from the data-model, rather than calculated by the template.
FreeMarker模板不进行日历计算,或者至少不进行日历计算,除非您为它们添加TemplateMethodModelEx。但原则上这些数据应来自数据模型,而不是模板计算。
Though, depending on how you define "days ago", something like ((.now?long - someDate?long) / 86400000)?ceiling
might works, assuming someDate
is a real date-time value and not just a string. But it's ugly.
虽然,取决于你如何定义“几天前”,像((。现在?long - someDate?long)/ 86400000)?ceiling可能会起作用,假设someDate是一个真正的日期时间值而不仅仅是一个字符串。但它很难看。
#1
0
FreeMarker templates don't do calendar calculations, or at least not unless you add a TemplateMethodModelEx
for them. But in principle such data should come from the data-model, rather than calculated by the template.
FreeMarker模板不进行日历计算,或者至少不进行日历计算,除非您为它们添加TemplateMethodModelEx。但原则上这些数据应来自数据模型,而不是模板计算。
Though, depending on how you define "days ago", something like ((.now?long - someDate?long) / 86400000)?ceiling
might works, assuming someDate
is a real date-time value and not just a string. But it's ugly.
虽然,取决于你如何定义“几天前”,像((。现在?long - someDate?long)/ 86400000)?ceiling可能会起作用,假设someDate是一个真正的日期时间值而不仅仅是一个字符串。但它很难看。