7 examples of 'get epoch time python' in Python

Every line of 'get epoch time python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
101def epoch2datetime(epoch):
102 return datetime.datetime.utcfromtimestamp(epoch)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

111def filetime_to_epoch(filetime):
112 return int(filetime / 10000000 - 11644473600)
470def _to_epoch_time(date):
471 """Convert a `datetime` object to an integer number of seconds since
472 the (local) Unix epoch.
473 """
474 epoch = datetime.fromtimestamp(0)
475 delta = date - epoch
476 return int(delta.total_seconds())
27def milliseconds_since_epoch():
28 return int(time.time() * 1000)
267@staticmethod
268def epochfromtime(t):
269 return calendar.timegm(t)
54def totimestamp(inputdate, epoch=datetime(1970,1,1)):
55 dt = datetime.strptime(inputdate, '%Y-%m-%d')
56 td = dt - epoch
57 timestamp = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 1e6 # td.total_seconds()
58 return int(timestamp)
13def timestamp():
14 return calendar.timegm(pytz.utc.localize(datetime.datetime.utcnow()).timetuple())

Related snippets