Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Formatting time (See related posts)

>>> from e32db import format_time
>>> from time import *
>>> t = time()
>>>
>>> format_time(t)   # for Symbian SQL
u'06/03/2006 23:26:35'
>>> strftime('%d/%m/%Y %H:%M:%S')  # like above
'06/03/2006 23:26:39'
>>> ctime()
'Mon Mar 06 23:26:49 2006'
>>> strftime("%a, %d %b %Y %H:%M:%S +0000")  # email RFC
'Mon, 06 Mar 2006 23:26:59 +0000'

Here's the (shortened) table for strftime.
%a  weekday name.  
%A  weekday name (full).  
%b  month name.  
%B  month name (full).  
%c  date and time (locale)
%d  day of month [01,31].  
%H  hour [00,23].  
%I  hour [01,12].  
%j  day of year [001,366].  
%m  month [01,12].  
%M  minute [00,59].  
%p  AM or PM
%S  Second [00,61]
%U  week of year (Sunday)[00,53].
 w  weekday [0(Sunday),6].
 W  week of year (Monday)[00,53].
 x  date (locale).
%X  time (locale).
%y  year [00,99].
%Y  year [2000].
%Z  timezone name.  

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts