Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Difference between two dates and times in python

# Timedelta function demonstration
from datetime import datetime, timedelta

# Using current time
time_for_now = datetime.now()

# printing initial_date
print("initial_date", str(time_for_now))

# Some another datetime
new_final_time = time_for_now + 
                timedelta(days=2)

# printing new final_date
print("new_final_time", str(new_final_time))


# printing calculated past_dates
print('Time difference:', str(new_final_time - time_for_now))
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Difference #dates #times #python
ADD COMMENT
Topic
Name
1+8 =