py3k: datetime resolution / isoformat

Ned Deily nad at acm.org
Sat Feb 26 03:49:10 CET 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