simple way to drop milliseconds from python datetime.datetime object -


this question has answer here:

my colleague needs me drop milliseconds python timestamp objects in order comply old posix (ieee std 1003.1-1988) standard. tortured route accomplishes task me follows:

datetime.datetime.strptime(datetime.datetime.today().strftime("%y-%m-%d %h:%m:%s"),"%y-%m-%d %h:%m:%s") 

is there simpler way end datetime.datetime object mongodb this?

you can use datetime.replace() method -

>>> d = datetime.datetime.today().replace(microsecond=0) >>> d datetime.datetime(2015, 7, 18, 9, 50, 20) 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -