Mayur
Mayur

Reputation: 2721

Python 3.6.X: Different values of from timestamp on Windows and Linux

Following script gives different output on Windows and Linux OS.

import datetime
datetime.datetime(2013, 12, 10, 12, 57, 4).timestamp()

Followings are the output depending on os

I am curious to know why there is a difference?

Upvotes: 1

Views: 757

Answers (1)

Mayur
Mayur

Reputation: 2721

Solved!
If you see time difference it's seconds = 19800 or minutes=330 or hrs=5:30
Two machines can have different timezone setting.
Use UTC timezone to compare timestamp.
eg.

from datetime import datetime, timezone
datetime(2013, 12, 10, 12, 57, 4, 0, timezone.utc).timestamp()

Upvotes: 2

Related Questions