473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 1262
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Grant Edwards | last post by:
Is it true that a datetime object can convert itself into a string, but not the other way around? IOW, there's no simple way to take the output from str(d) and turn it back into d? So, I tried...
6
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a...
8
by: Jimmie | last post by:
Hiya all, very quick question, I hope .. I have an xml dump of some old data that I need to parse and input into a new system. A couple of date fields are in there that have the following data...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
8
by: Alan Silver | last post by:
Hello, I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient. I...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
0
by: maolimix | last post by:
Hi to all, I have a trouble with datetime...now I explain.. I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005. I tried 3 methods ...in the first two I never...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.