Ok, so I'm converting strings to date so far by:
datetime.datetime.fromtimestamp(time.mktime(time.strptime(date_string, DB_TIME_FORMAT)))
But I'm getting some strange results. For example for:
date_string = '2011-08-30 12:52:57.573979'
DB_TIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f'
The result is:
2011-08-30 12:52:57
So I guess my first question is where did the milliseconds go?
My second question would be is there a way to make a "dynamical" string to time conversion? By this I mean, let's say for the format in my previous example, if the milliseconds are not present, instead of getting a ValueError if will still return a normal date. If seconds are missing the same situation and so on?
regards, Bogdan
.573979- looks like microseconds, not milliseconds.