How to check datetime in python3?
Both date and time are same but in 'b' there is no zero.
a = '2020-09-08 05:09:02'
b = '2020-9-8 5:9:2'
if a == b:
print("yes")
else:
print("no")
Expected Output:
yes
How to check datetime in python3?
Both date and time are same but in 'b' there is no zero.
a = '2020-09-08 05:09:02'
b = '2020-9-8 5:9:2'
if a == b:
print("yes")
else:
print("no")
Expected Output:
yes
you can turn them into datetime
objects and compare them
import datetime as dt
a = '2020-09-08 05:09:02'
b = '2020-9-8 5:9:2'
a_dt = dt.datetime.strptime(a, '%Y-%m-%d %H:%M:%S')
b_dt = dt.datetime.strptime(b, '%Y-%m-%d %H:%M:%S')
if a_dt == b_dt:
print("yes")
else:
print("no")