py3k: datetime resolution / isoformat

Ned Deily nad at acm.org
Fri Feb 25 21:49:10 EST 2011


In article <ssZ9p.10276$5v7.5466 at newsfe11.iad>, spam at uce.gov wrote:
> When I do:
> 
>      datetime.datetime.now().isoformat(' ')
> 
> I get the time with the microseconds. The docs says:
> "if microsecond is 0 YYYY-MM-DDTHH:MM:SS+HH:MM".
> 
> How do I set microsecond to 0?

>>> datetime.datetime.now().replace(microsecond=0).isoformat()
'2011-02-25T18:48:24'

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list