simple way to drop milliseconds from python datetime.datetime object -
this question has answer here:
- truncate python datetime 10 answers
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
Post a Comment