将字符串转换为django中的datetime? [英] Convert string to datetime in django?
本文介绍了将字符串转换为django中的datetime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
如果您绝对必须这样做,请使用 time.strptime
。尽管如此,如果您可以避免将结构化数据存储在字符串中,那将是一个更好的主意。
i want to display time in 12 hour format in django templates as iam storing time data in a charecter eg('18:30:00') field how to convert this string time data to date in django/python?
解决方案
If you absolutely must do this, use time.strptime
. It would be a better idea not to store structured data in a string if you can avoid it, though.
这篇关于将字符串转换为django中的datetime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文