gpt4 book ai didi

python - OpenERP 6.1 日期时间格式

转载 作者:太空宇宙 更新时间:2023-11-03 19:05:40 24 4
gpt4 key购买 nike

为什么

o.create_order.strftime("%d %B %Y")

什么时候都不返回

time.strftime("%d %B %Y")

返回日期“2013 年 2 月 10 日”???

o.create_order 是根据 postgresql 的时间戳。它包含“30/11/2012 09:38:34”,如 openErp 销售订单 - 其他信息选项卡上所示。查询数据库时存储为“2012-11-30 08:38:34.272”。所以我希望看到“2012 年 11 月 30 日”,但什么也没得到。我是否误解了语法?

我从 python 3.3 测试了这个:

>>> d1=datetime.datetime.today()
>>> print(d1.strftime("%d %B %Y"))
10 february 2013

如何让它在 OpenOffice Writer 中工作?

顺便问一下,我如何获得“二月”而不是“二月”?

最佳答案

因为 o.create_order 返回字符串而不是日期时间对象,即使在内部数据库列是时间戳。 OpenERP ORM 返回 ISO 8601 格式的字符串。

您需要使用 RML 报告中提供的 formatLang 方法,或使用 datetime python 模块创建 datetime 对象。

试试这个:

datetime.strftime('%d %B %Y', o.create_order')

关于python - OpenERP 6.1 日期时间格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14802307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com