A timestamp is the number of seconds since Jan 1, 1970 00:00:00. There are multiple ways to get the current timestamp in Python. You can use functions from time, datetime, or calendar modules. Here are some examples.
# Using time. import time ts = time.time() print("Using time :", ts) # Using datetime. import datetime ts = datetime.datetime.now().timestamp() print("Using datetime: ", ts) # Using calendar. import calendar import time ts = calendar.timegm(time.gmtime()) print("Using calendar: ", ts)
Output
Using time : 1560375010.7313197 Using datetime: 1560375010.732931 Using calendar: 1560375010