PYTHON date_diff

is this article helpful?
|
Python replacement for PHP's date_diff [ edit | history ]
from datetime import datetime

def date_diff(day1, day2):
    date_format = "%Y-%m-%d"
    a = datetime.strptime(day1, date_format)
    b = datetime.strptime(day2, date_format)
    delta = b - a
    return delta.days


Using:
date_diff( '2019-01-01', '2019-06-03' )
# 153

PHP date_diff

PHP original manual for date_diff [ show | php.net ]

date_diff

(PHP 5 >= 5.3.0)

date_diffAlias of DateTime::diff

Description

This function is an alias of: DateTime::diff