[PythonCE] Timestamp

Matt S. sleepingbull at gmail.com
Wed Jul 19 02:28:23 CEST 2006


I've found the datetime module to be very useful.  Using datetime, you can
use its strftime method to format the print method of datetime objects to
your hearts content.  Or, use it with matplotlib, and more.  There's also
the mxDatetime modules (though not part of the standard distribution).

A datetime example,

import datetime
tNow = datetime.datetime.now()
tFmt = tNow.strftime('%Y%m%d%H%M%S')

On 7/18/06, Alex Mandel <tech_dev at wildintellect.com> wrote:
>
> Alex Mandel wrote:
> > So I was looking at an old post where someone used
> >
> > Python 2.3.2 (#0, Dec 11 2003, 12:46:49) [MSC v.1200 32 bit (Unknown)]
> on
> > Pocket PC
> >  >>> >>> import time
> >  >>> >>> clock=time.clock()
> >  >>> >>> local=time.localtime(clock)
> >  >>> >>> local
> > (2004, 2, 27, 10, 14, 41, 4, -1, -1)
> >
> > When I tried to repeat that on my Dell Axim X5 and on the Desktop
> > Emulator I always get
> > (1969,12,31,17...
> > Any idea how to actually get the time.
> > All I need is string that has mmddyy like 071806
> >
> > I tried:
> > import time
> > from time import strftime
> > strftime("%m%d%y",gmtime())
> > and got and error
> > NameError: name 'gmtime' is not defined
> > if I throw in local from the above code it works except its not the
> > current time its the default microsoft time.
> >
> > Any ideas? Thanks -
> > Alex
> NVM - localtime() worked
>
> _______________________________________________
> PythonCE mailing list
> PythonCE at python.org
> http://mail.python.org/mailman/listinfo/pythonce
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonce/attachments/20060718/41fbe751/attachment.htm 


More information about the PythonCE mailing list