Get the time stamp format of time in python

Viewed 28

How can i get this format of time in python is there any suggestion about it

var ti = Date.now() + parseFloat(Math.random().toFixed(8))
1609193057063.8418
1 Answers

You can do this:

from datetime import datetime

print(datetime.now().timestamp())

Or simpler:

import time

print(time.time())

Which will output:

1609193535.115763

You can then, using slicing, cut the decimals at the end or just use the decimal stdlib to aproximate the last 4 decimals.

Related