datetime question

Jorge Godoy godoy at ieee.org
Tue Apr 18 15:20:49 EDT 2006


Philippe Martin wrote:

> Hi,
> 
> I need to get the date and time under Windows and Linux but need the
> information visible to the user (cannot find my words) not the sytem
> information (ex: a PC setup on greenwich but the date/time displayed are
> relative to some other place.

Something like this?

>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2006, 4, 18, 16, 19, 42, 159000)
>>> print datetime.datetime.now()
2006-04-18 16:19:45.245053
>>> dir(datetime.datetime.now())
['__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__',
'__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__',
'__rsub__', '__setattr__', '__str__', '__sub__', 'astimezone', 'combine',
'ctime', 'date', 'day', 'dst', 'fromordinal', 'fromtimestamp', 'hour',
'isocalendar', 'isoformat', 'isoweekday', 'max', 'microsecond', 'min',
'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime',
'time', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname',
'utcfromtimestamp', 'utcnow', 'utcoffset', 'utctimetuple', 'weekday',
'year']
>>> 

-- 
Jorge Godoy      <godoy at ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.



More information about the Python-list mailing list