4 examples of 'linux convert epoch to date' in Python

Every line of 'linux convert epoch to date' 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

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())
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)
111def filetime_to_epoch(filetime):
112 return int(filetime / 10000000 - 11644473600)

Related snippets