59426

Counting passed seconds

Question:

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?

Answer1:

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 <a href="http://docs.python.org/library/datetime.html" rel="nofollow">here</a>.

Recommend

  • How to get desired format from ArrayList
  • two ways of displaying a decimal
  • Globalized custom number formatting - Variable decimal points
  • Why is it still possible to insert a foreign key that doesn't exist?
  • MySql - get days remaining
  • Returning this from a constructor function in JS
  • What is the use of a session store?
  • How to get the date of next specified day of week
  • Using Sax parsing to edit and write XML in VB6
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • ActiveRecord query for a count of new users by day
  • Django rest serializer Breaks when data exists
  • Is it possible to access block's scope in method?
  • Checking free space on FTP server
  • Meteor helpers not available in Angular template
  • Can I check if a recipient has an automatic reply before I send an email?
  • C++ Partial template specialization - design simplification
  • Django: Count of Group Elements
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Is there a javascript serializer for JSON.Net?
  • Illegal mix of collations for operation for date/time comparison
  • Sending data from AppleScript to FileMaker records
  • MySQL WHERE-condition in procedure ignored
  • Where to put my custom functions in Wordpress?
  • align graphs with different xlab
  • Return words with double consecutive letters
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Buffer size for converting unsigned long to string
  • python regex in pyparsing
  • using HTMLImports.whenReady not working in chrome
  • Android Google Maps API OnLocationChanged only called once
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Reading document lines to the user (python)
  • Binding checkboxes to object values in AngularJs
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?