开发者

If 'timesince' is over 24 hours then just display the day count and not the hours count

If a question posted i开发者_运维问答s over 24 hours old then I want to limit it to show the day count and not the hours count. Obviously if under 24 hours old then show the hours count.

Currently: Asked 1 day, 18 hours ago

Optimal: Asked 1 day ago

{{question.created|timesince}}

Still fairly new to Django, any help would be appreciated.


Have a look at naturaltime: https://docs.djangoproject.com/en/dev/ref/contrib/humanize/#naturaltime

It should give you what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜