473,390 Members | 1,034 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,390 software developers and data experts.

Get System Date?

Is it possible to get the system date on a Windows XP machine? Most
Convenient would to retrieve YYYY, MM, and DD as seperate variables.

When I say system date, I'm thinking of the small clock in the
lower-right hand corner, which has date as well as time, but if there's
another clock that Python supports, it works for me as long as it's
somewhat accurate.

Feb 5 '06 #1
5 10790
Dustan:
Is it possible to get the system date on a Windows XP machine?


Most certainly:
http://www.python.org/doc/lib/module-time.html

--
René Pijlman
Feb 5 '06 #2
Dustan,

Python has a module called, appropriately, "time". Like most things in
Python, it's fairly simple and straightforward to use.

The module is documented here:
http://docs.python.org/lib/module-time.html

Breifly, though, the format you want is built right into time:
import time
now = time.localtime()
print now

(2006, 2, 5, 13, 21, 15, 6, 36, 0)

So to get the year, month, and day you would just have to manipulate
the values returned by time.gmtime().

- Dave

Feb 5 '06 #3
Thanks

Feb 5 '06 #4
Dustan <Du**********@gmail.com> wrote:
Is it possible to get the system date on a Windows XP machine? Most
Convenient would to retrieve YYYY, MM, and DD as seperate variables.

When I say system date, I'm thinking of the small clock in the
lower-right hand corner, which has date as well as time, but if there's
another clock that Python supports, it works for me as long as it's
somewhat accurate.

import datetime
x=datetime.date.today()
yyyy, mm, dd = x.year, x.month, x.day
print yyyy 2006 print mm 2 print dd 5


As you see, these are integers (so, for example, mm is not '02' but just
2). Pretty easy to make them into strings, of course, if you want.
Alex
Feb 5 '06 #5
Dave wrote:
Dustan,

Python has a module called, appropriately, "time".


This is basically a wrapper around the standard C time
library. Python has a more modern and spiffy datetime
module which isn't restrained to 1970-2038, and just
handles spiffy date and datetime objects instead of
making you deal with awkward conversions between strange
numbers and obscure tuples. The old time module does work,
but due to e.g. strange assymetries in the module, you
have to deal with strange quirks to convert UTC times
right...
import datetime
datetime.datetime.now()

datetime.datetime(2006, 2, 5, 23, 1, 45, 569833)
Feb 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
11
by: Mike9900 | last post by:
How can I get the real system date/time if the user fakes the date, for example by setting the system date back. -- Mike
3
by: Carlos Lozano | last post by:
I have requirement to pause the system clock until a certain event (Win XP). Then the clock will be resumed to the real time. I think it can be done using core functions and/or redirecting the...
1
by: shyam vashista | last post by:
i have problem in validation check for system date with server date problem::: If i change my system date as september 30, 2006 and use validation for filling form as current date as oct30,...
5
by: adie | last post by:
hi, can anyone help me out with this. the requirement is to display a time (any time) from a distinct timezone (lets say EST) on a webpage but to make available the conversion to the user local...
15
by: iffa n wanie | last post by:
Develop a library information system that provides the following functionalities: a) Add New Patron b) Search Patron c) Check Out Book The patron ID is unique and is generated automatically...
4
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system...
2
by: samvb | last post by:
Hi, I have just finished a program that uses ms access and depends on system date to do certain things. just when i was testing it, a friend suggested that i change system date to see how it reacts....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.