user@machine:~$ date
Tue Jan 12 09:22:56 UTC 2021
const getTimestamp = (date = new Date()) => Math.floor(date.getTime() / 1000);
getTimestamp(); // 1602162242
import calendar
import datetime
date = datetime.datetime.utcnow()
utc_time = calendar.timegm(date.utctimetuple())
print(utc_time)
import time
import datetime
d = datetime.date(2015,1,5)
unixtime = time.mktime(d.timetuple())
unixtime
$ date +%s ## gives UNIX timestamp at command line