About 5,960,000 results
Open links in new tab
  1. How do I check the difference, in seconds, between two dates?

    if you want to compute differences between two known dates, use total_seconds like this: import datetime as dt a = dt.datetime(2013,12,30,23,59,59) b = dt.datetime(2013,12,31,23,59,59) (b …

  2. In Python, how do you convert a `datetime` object to seconds?

    Dec 6, 2018 · I have a bunch of datetime objects and I want to calculate the number of seconds since a fixed time in the past for each one (for example since January 1, 1970). import …

  3. python - How to calculate number of days between two given dates

    To get the same absolute value no matter which direction the subtraction happens, we can get the timedelta in total seconds and convert that number into number of days by dividing it by …

  4. How to get Number of Seconds between Two Dates in Python?

    Learn how to calculate the number of seconds between two dates in Python using the datetime library. This tutorial outlines the steps, provides example code, and explains the use of the …

  5. Top 5 Methods to Calculate the Difference in Seconds Between

    Dec 5, 2024 · Explore various approaches to easily calculate the difference in seconds between two dates using Python.

  6. How to Calculate the Difference Between Two Dates in Python

    Jul 31, 2024 · This example demonstrates the basic way to calculate the difference between two dates using Python’s datetime module. By subtracting one datetime object from another, …

  7. Calculating the Difference Between Two Dates in Python

    Learn to calculate the difference between two dates in Python: comparing the current time with a specific datetime, between two datetime objects, two date objects, and dates in string format. …

  8. Python: Calculate two date difference in seconds - w3resource

    Apr 22, 2025 · Write a Python script that computes the total seconds between two datetime objects and then formats the result into hours, minutes, and seconds. Write a Python function …

  9. 5 Best Ways to Calculate Python Datetime Delta in Seconds

    Feb 28, 2024 · The timedelta.total_seconds() method returns the total number of seconds contained in the duration represented by a datetime.timedelta object. This method provides a …

  10. Number of Hours, Minutes & Seconds Between datetimes in Python

    Calculate Number of Hours, Minutes & Seconds Between Two datetimes in Python (3 Examples) In this article you’ll learn how to compute the number of hours, minutes, and seconds between …

Refresh