0

I am trying to set the specific time and display as second like time.time() does. Let's say I want to display exact time 2019/1/1 12:00 AM.

The code would be

datetime.datetime(2019, 1, 1, 0, 0).timestamp()

But, if I wanted to make sure it is in specific time zone (like AST, EST). How can I do that?

GothLoli
  • 19
  • 1
  • 6

1 Answers1

0

Question answered here: Display the time in a different time zone

Here is the essential code from one of the answers:

from datetime import datetime
from pytz import timezone    

south_africa = timezone('Africa/Johannesburg')
sa_time = datetime.now(south_africa)
print sa_time.strftime('%Y-%m-%d_%H-%M-%S')
RoM
  • 52
  • 4