Archived:How to get current date and time in PySymbian
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
The article is believed to be still valid for the original topic scope.
The article is believed to be still valid for the original topic scope.
This article describes some ways to get current date and time using PySymbian.
Article Metadata
#import time module
>>> import time
>>> time.localtime()
#The localtime function returns the following tuple
(2008, 4, 24, 14, 36, 8, 3, 115, 0)
>>> time.localtime()[0]
#Returns the current year
2008
>>> time.localtime()[1]
#Returns the current month
4
>>> time.localtime()[2]
#Returns the current date
24
>>> time.localtime()[3]
#Returns the current time - hour
14
>>> time.localtime()[4]
#Returns the current time - minutes
36
>>> time.localtime()[5]
#Returns the current time - seconds
3
>>> time.time()
#Returns seconds elapsed since 1/1/1970 00:00:00
1209040719.4159999
#################################
#Other method using for loop
start = time.clock()
for x in range(1000000):
y = x # do something
end = time.clock()
print "Time elapsed = ", end - start, "seconds"
There is a module datetime,which has been adapted to Python S60 so you can use it and install it as lib.
Here is a link to the related article which mentions how to handle date and time.


20 Sep
2009
25 Sep
2009