Linked Questions
19 questions linked to/from How can I parse a time string containing milliseconds in it with python?
6 votes
3 answers
15k views
python strptime correct format for sub seconds [duplicate]
My datetime data is like this: 2016-03-01 19:25:53.053404 I am trying to use datetime.strptime(date, "%Y-%m-%d %HH:%MM:%SS") But I get this error: ValueError: time data '2016-03-01 19:24:35....
0 votes
1 answer
1k views
Converting string with decimals into datetime [duplicate]
This question is very similar to this SO, but my data is on the form: '13-04-2018 14:06:26.866' '13-04-2018 14:06:27.131' '13-04-2018 14:06:27.404' '13-04-2018 14:06:27.674' ... i.e. the seconds are ...
2 votes
1 answer
362 views
Python time with milliseconds [duplicate]
I have a following datetime: d1 = 2015-03-21 14:50:54.0. While doing datetime.strptime(d1, "%Y-%m-%d %H:%M:%S") I get an error that ValueError: unconverted data remains: .0. How can I add ...
-1 votes
1 answer
108 views
"2013-10-21 12:00:00.004" string convert to datetime in Python [duplicate]
How to convert "2013-10-21 12:00:00.004" to datetime object in Python? The problem is there is decimal number in seconds.
-1 votes
1 answer
87 views
why is datetime.strptime not working unable to format? [duplicate]
i am reading a entrance time from sqlite database to calaulate the duration of the car stay. the datetime is currenly able to insert and retrive but when formated to do calualtion it keeps give an ...
1 vote
0 answers
24 views
How to convert time string with very precise time measurements to date objects using strptime()? [duplicate]
From some sensor I obtained very precise time measurement given as this: time_str = '2019-07-03T20:03:51.520273066Z' Using the datetime library, I'm trying to convert it to datetime object: time_obj ...
308 votes
18 answers
204k views
Python logging: use milliseconds in time format
By default logging.Formatter('%(asctime)s') prints with the following format: 2011-06-09 10:54:40,638 where 638 is the millisecond. I need to change the comma to a dot: 2011-06-09 10:54:40.638 To ...
11 votes
2 answers
25k views
What would be the Python code to add time to a specific timestamp?
Trying to figure out datetime module and need some help. I've got a string which looks like this: 00:03:12,200 --> 00:03:14,316 (that is hours:minutes:seconds,milliseconds) and need to add let's ...
3 votes
2 answers
1k views
Microsecond part lost when converting a date string to a datetime object in python
I have the following date string: dtstr = '2010-12-19 03:44:34.778000' I wanted to convert it to a datetime object, so i proceeded as follows: import time from datetime import datetime dtstr = '...
1 vote
2 answers
2k views
Python convert string to datetime for comparison to datetime object
I have a string lfile with a datetime in it (type(lfile) gives <type 'str'>) and a Python datetime object wfile. Here is the code: import os, datetime lfile = '2005-08-22_11:05:45.000000000' ...
5 votes
1 answer
2k views
How to create a Django custom Field to store MYSQL DATETIME(6) and enable fractional seconds (milliseconds and or microseconds) in Django/MySQL?
MySQL 5.6.4 and up expands fractional seconds support for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision: http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds....
0 votes
2 answers
2k views
Search text file for a time range - python
I am playing around with python and I am trying to figure out a way to search a text file for a specific word within a time range. The file has time stamps, however since the file is a text file ...
1 vote
2 answers
755 views
How to parse time.time()?
I see how How can I parse a time string containing milliseconds in it with python? provides a solution when parsing a full timestamp and Is there an inverse function for time.gmtime() that parses a ...
0 votes
1 answer
590 views
correct parsing for a str date time in ddmmyyyy:HH:MM:SS.xxx format
I have the following datetime values in dask dataframe saved as string dates: ddf = dd.DataFrame({'date': ['15JAN1955:13:15:27.369', NaN,'25DEC1990:23:18:17.200', '06MAY1962:02:55:27.360', NaN, '...
0 votes
1 answer
234 views
appengine import_transform two function at the same time: truncate & export_date_time
I have this datetime 2011-07-02 03:03:32.793 To deal with the millisecond issue with python 2.5 version(mentioned here), I try to truncate it & convert it date time as: import_transform: '...