Python datetime instruction issue

Asked by Kunal

HI
I am trying to extract the current date, month, year from a python instruction in Sikuli.
In course i used instructions like
1) localtime = time.asctime( time.localtime(time.time()))
2) localtime = time.localtime(time.time())

I failed with the first one as the array element position was changed.
Now i am using the second one to extract the datetime.

I want to know that is this problem frequent. If yes, then how can i avoid it. Is there a probable workaround.
If no then is there a specific interval after which the array element position interchanges?

Hope for your early response.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

I am using time.strftime(string, time) for these purposes
look: http://docs.python.org/library/time.html#time.strftime

(no import time needed, since already available through Sikuli)

e.g.
time.strftime('%Y')

returns a string containing '2011'

if the second parameter time is omitted, it uses the actual localtime() internally.

So if you run a script and use
start = time.time()

you may later on say:
time.strftime('%Y', time.localtime(start))

to get the relevant parts of the start time.

Revision history for this message
Kunal (kunalzunjarrao) said :
#2

Thanks Sir, it was helpful.