How to get the current date and time with milliseconds accuracy in Python

1 Answer

0 votes
from datetime import datetime

datetime_str = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]

print(datetime_str)



'''
run:

2024-12-06 10:09:59.336

'''

 



answered Dec 6, 2024 by avibootz
...