python timestamp code example
Example 1: python get date and time
import datetime
now = datetime.datetime.now()
print ("Current date and time : ")
print (now.strftime("%Y-%m-%d %H:%M:%S"))
Example 2: python print timestamp
import datetime
ts = datetime.datetime.now().timestamp()
Example 3: python get timestamp of today
import datetime;
ts = datetime.datetime.now().timestamp()
Example 4: timestamp python
from datetime import datetime
now = datetime.now()
timestamp = datetime.timestamp(now)
print("timestamp =", timestamp)
Example 5: timestamp change python
import time
timestamp = 1547281745
datetime = time.strftime('%A, %Y-%m-%d %H:%M:%S', time.localtime(timestamp))
print(datetime)
Example 6: timestamp to date python
from datetime import datetime
timestamp = 1586507536367
dt_object = datetime.fromtimestamp(timestamp)