469,616 Members | 1,652 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

datetime question

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.

Regards,

Philippe

Apr 18 '06 #1
4 1160
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 <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Apr 18 '06 #2
Thanks, yes, I guess the question is ... what date/time is it looking at ?
and is it the same under various OSs ?
Philippe
Jorge Godoy wrote:
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 <go***@ieee.org>

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


Apr 18 '06 #3
Jorge Godoy wrote:
Philippe Martin wrote:
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() ...


Just so you (Phillipe) know, you are talking about "local time" vs. UTC.
import datetime
print datetime.datetime.now() # local 2006-04-18 15:25:03.140000 print datetime.datetime.utcnow() # zulu / utc / gmt

2006-04-18 22:25:13.625000

--Scott David Daniels
sc***********@acm.org
Apr 18 '06 #4
:-)

Thanks.

Philippe
Scott David Daniels wrote:
Jorge Godoy wrote:
Philippe Martin wrote:
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()

...


Just so you (Phillipe) know, you are talking about "local time" vs. UTC.
>>> import datetime
>>> print datetime.datetime.now() # local 2006-04-18 15:25:03.140000 >>> print datetime.datetime.utcnow() # zulu / utc / gmt

2006-04-18 22:25:13.625000

--Scott David Daniels
sc***********@acm.org


Apr 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Grant Edwards | last post: by
6 posts views Thread by Carl | last post: by
8 posts views Thread by Jimmie | last post: by
3 posts views Thread by Andrew S. Giles | last post: by
8 posts views Thread by Alan Silver | last post: by
26 posts views Thread by Reny J Joseph Thuthikattu | last post: by
9 posts views Thread by Phil B | last post: by
5 posts views Thread by iulian.ilea | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.