将字符串中的时间转换为dateTime.datetime

发布于 2025-02-11 14:36:56 字数 8 浏览 2 评论 0原文

continue

I have a time in the form time = '2022-06-29 07:55:28' that has the type str I want to store it in the firebase in the firebase's format. For that I have tried datetime.strptime(time, '%Y %m %d %I:%M:%S%p'). But I am getting the following error:

ValueError: time data '2022-06-29 07:55:28' does not match format '%Y %m %d %I:%M:%S%p'

Kindly help me out in this. Should I go for momentjs or something similar?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慵挽 2025-02-18 14:36:56

我进入错误的格式。应该是

time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S')

注意:我们必须根据给出的数据的格式输入格式!

I was entering the wrong format. It should have been

time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S')

Note: We have to enter the format according to the format of the data given!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文