String to datetime variable format
<p>Ok, so I'm converting strings to date so far by:</p>

<pre><code>datetime.datetime.fromtimestamp(time.mktime(time.strptime(date_string, DB_TIME_FORMAT)))
</code></pre>

<p>But I'm getting some strange results. For example for:</p>

<pre><code>date_string = '2011-08-30 12:52:57.573979'
DB_TIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f'
</code></pre>

<p>The result is:</p>

<pre><code>2011-08-30 12:52:57
</code></pre>

<p>So I guess my first question is where did the milliseconds go?</p>

<p>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?</p>

<p>regards,
Bogdan </p>
