将字符串转换为django中的datetime? [英] Convert string to datetime in django?

查看:787
本文介绍了将字符串转换为django中的datetime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在django模板中以12小时格式显示时间,因为iam在charecter中存储时间数据,例如('18:30:00')字段如何在django / python?中将此字符串时间数据转换为日期? p>

解决方案

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆