How can we count the number of seconds passed since the start of the day 0.00 ? Is there a module function or do we have to do it ourselves?
Asked
Active
Viewed 1.5k times
1 Answers
9
from datetime import datetime, time
now = datetime.now()
beginning_of_day = datetime.combine(now.date(), time(0))
print (now - beginning_of_day).seconds
See docs for datetime
module here.

KL-7
- 46,000
- 9
- 87
- 74
-
That solves the windows problem, but how to do it in pys60. There is no datetime module in it. – Dinesh Khadka Dec 17 '11 at 10:54
-
1If you were interested in solution for pys60 you'd better specify that in the first place. Looks like you can add `datetime` module manually. Have a look at [this snippet](http://snippets.dzone.com/posts/show/1614). – KL-7 Dec 17 '11 at 11:04
-
I initially tagged it pys60 but everytime I submitted my question an error (quality standards) kept coming ani I edited the title and tagged it python and it somehow worked. But, thanks It'll help me a lot – Dinesh Khadka Dec 17 '11 at 12:19