Reputation: 10636
I need to convert current date time to epoch time in python.
I have tried this, but I am not sure is this tz="New_York/Americas". Is below right?
import time
epoch_time = int(time.time())
Upvotes: 1
Views: 115
Reputation: 2245
You can use python's calendar module for this.
from datetime import datetime
from calendar import timegm
current_time = datetime.utcnow()
epoch_time = timegm(current_time.utctimetuple())
For more, visit calendar's timegm.
Upvotes: 2