How to convert a Date string to a DateTime object?

后端 未结 3 1277
遇见更好的自我
遇见更好的自我 2020-11-30 05:06

I have following date:

2005-08-11T16:34:33Z

I need to know if this is date is before or after datetime(2009,04,01) and I can\'t se

3条回答
  •  无人及你
    2020-11-30 05:47

    If you know the string just use the datetime.datetime(year, month, day, hour, minute, second) function. Split your string to get the appropriate variables and put it in to make it a datetime type. Then just compare it against whatever you need.

    Or you can use the iso format as people have suggested also.

提交回复
热议问题