且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将字符串转换为django中的datetime?

更新时间:2023-10-22 14:49:16

如果您绝对必须这样做,请使用 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.