Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you remove seconds and milliseconds from a date time string in python

How I can convert a date in format "2013-03-15 05:14:51.327" to "2013-03-15 05:14", i.e. removing the seconds and milliseconds. I don't think there is way in Robot frame work. Please let me know if any one have a solution for this in python.

like image 646
PKR Avatar asked Mar 15 '13 09:03

PKR


1 Answers

Try this (Thanks Blender!)

>>> date = "2013-03-15 05:14:51.327"
>>> newdate = date.rpartition(':')[0]
>>> print newdate
2013-03-15 05:14
like image 117
TerryA Avatar answered Oct 29 '22 17:10

TerryA