Number of days between two dates

1
2
<?php
/**
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Calculate the number of days between two dates. The order of the dates is irrelevant and any date format supported by http://php.net/strtotime should work.

3 Responses

Hi, Sorry I'm a PHP newbie. Where to put in the two dates and in which format?

Thank you ;)
You can put the dates in any format accepted by http://php.net/strtotime so daysDiff('2016-02-01', '21/11/2011') would work.
It doesn't matter which order you put in the dates.
1
$days_diff = daysDiff('tomorrow', 'yesterday');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
and
1
$days_diff = daysDiff('yesterday', 'tomorrow');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
will both return the same result (2).

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.