How can I add N milliseconds to a datetime in Python

Use timedelta

To increment by 500 ms:

fulldate = datetime.datetime.strptime(date + ' ' + time, "%Y-%m-%d %H:%M:%S.%f")
fulldate = fulldate + datetime.timedelta(milliseconds=500)

You can use it to increment minutes, hours, days etc. Documentation:

https://docs.python.org/2/library/datetime.html#timedelta-objects

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)