How to get the date and time difference in seconds with python

I write it because I go around every time.

import datetime

#year,month,day,hour,minute,second(,micro?)Is the argument of the datetime method
first_time = datetime.datetime(2013,11,10,11,11,11)
last_time =  datetime.datetime(2014,11,10,11,11,11)
delta = last_time - first_time
print delta.total_seconds()
#=>31536000.0 total_Express the difference in seconds using seconds

Recommended Posts

How to get the date and time difference in seconds with python
Get the current date and time in Python, considering the time difference
To represent date, time, time, and seconds in Python
How to get the files in the [Python] folder
Get and convert the current time in the system local timezone with python
How to stop a program in python until a specific date and time
Convert timezoned date and time to Unixtime in Python2.7
How to get the variable name itself in python
How to get the number of digits in Python
How to get started with the 2020 Python project (windows wsl and mac standardization)
How to get a list of files in the same directory with python
How to get the Python version
How to get started with Python
How to calculate date with python
How to get the last (last) value in a list in Python
[Python] Display the elapsed time in hours, minutes, and seconds (00:00:00)
How to get all the keys and values in the dictionary
How to get into the python development environment with Vagrant
[Introduction to Python] How to get data with the listdir function
How to log in to AtCoder with Python and submit automatically
[Note] How to write QR code and description in the same image with python
Get date and time in specified format
How to work with BigQuery in Python
How to get a stacktrace in python
How to use is and == in Python
How is the progress? Let's get on with the boom ?? in Python
[Python] How to get the first and last days of the month
Difference in how to write if statement between ruby ​​and python
Get the title and delivery date of Yahoo! News in Python
How to calculate "xx time" in one shot with Python timedelta
How to display bytes in the same way in Java and Python
Recursively get the Excel list in a specific folder with python and write it to Excel.
How to use the C library in Python
[Python Kivy] How to get the file path by dragging and dropping
[Python] Get the files in a folder with Python
[REAPER] How to play with Reascript in Python
How to generate permutations in Python and C ++
[Python] How to change the date format (display format)
About the difference between "==" and "is" in python
Sample code to get the Twitter API oauth_token and oauth_token_secret in Python 2.7
How to measure execution time with Python Part 1
Get date in Python
How to use tkinter with python in pyenv
Get date with python
Memo of the program to get the date in two digits with javascript, Ruby, Python, shell script
How to plot autocorrelation and partial autocorrelation in python
How to measure execution time with Python Part 2
How to pass the path to the library built with pyenv and virtualenv in PyCharm
Convert the world time zone time string to Japan time without calculating the time difference with python.
I'm addicted to the difference in how Flask and Django receive JSON data
Note: How to get the last day of the month with python (added the first day of the month)
I want to get the file name, line number, and function name in Python 3.4
[Introduction to Python] How to get the index of data with a for statement
Extract "current date only" and "current date and time" with python datetime.
How to retrieve the nth largest value in Python
How to do hash calculation with salt in Python
How to measure processing time in Python or Java
Convert date timezone (time difference) in Python (from string)
[Introduction to Python] How to iterate with the range function?
How to know the current directory in Python in Blender
Explain in detail how to make sounds with python