Wednesday, March 20, 2019

python - Are these two formatting date methods really equivalent?

It seems that:




time.strftime("%Y-%m-%d %H:%M:%S")
#2017-01-12 10:46:57

datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
#2017-01-12 10:46:57


are equivalent. When I read many questions/answers here, or tutorials or documentation, some of them use the former, some the latter.



Are they 100% equivalent? When to prefer the one or the other?




PS: the latter seems to be equivalent to datetime.date.fromtimestamp(time.time()), but is this equivalent to time.strftime(...)?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...