开发者

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

开发者 https://www.devze.com 2023-04-04 15:18 出处:网络
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.

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

精彩评论

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