Formatting date in Web2py Python

点点圈 提交于 2019-12-05 16:28:17

If your goal is to display on web2py template, so you have to use pure Python to format

{{=row.datetime_field.strftime("%d/%m/%Y")}}

The above will generate 25/09/2012

Tale a look at Python strftime documentations.

If you want to show only the day.

{{=row.datetime_field.date}}

Also you can set it as a representation for that field

db.mytable.datetime_field.represent = lambda value, row: value.strftime("format-here")

The representation will be useful only on SQLFORM.grid and SQLTABLE

All you need is strftime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!