×
Namespaces

Variants
Actions

Archived:How to get current date and time in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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.


This article describes some ways to get current date and time using PySymbian.

Article Metadata
Article
Created: User:Kandyfloss (24 Apr 2008)
Last edited: hamishwillee (08 May 2013)
#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.

This page was last modified on 8 May 2013, at 08:24.
50 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×