Hello,
How to find number of days between two dates using php.
for this i have test the answer of:
Calculate number of days between two dates in PHP [closed] (3)
on this forum.
but it does not work.
can any one help me.
Hello,
How to find number of days between two dates using php.
for this i have test the answer of:
Calculate number of days between two dates in PHP [closed] (3)
on this forum.
but it does not work.
can any one help me.
If you have the times in seconds (I.E. unix time stamp) , then you can simply subtract the times and divide by 86400 (seconds per day)
Convert your dates to unix timestamps, then substract one from the another. That will give you the difference in seconds, which you divide by 86400 (amount of seconds in a day) to give you an approximate amount of days in that range.
If your dates are in format 25.1.2010, 01/25/2010 or 2010-01-25, you can use the strtotime function:
$start = strtotime('2010-01-25');
$end = strtotime('2010-02-20');
$days_between = ceil(abs($end - $start) / 86400);
Using ceil rounds the amount of days up to the next full day. Use floor instead if you want to get the amount of full days between those two dates.
If your dates are already in unix timestamp format, you can skip the converting and just do the $days_between part. For more exotic date formats, you might have to do some custom parsing to get it right.
<?php
$now = time(); // or your date as well
$your_date = strtotime("2010-01-01");
$datediff = $now - $your_date;
echo floor($dateDiff/(60*60*24));
?>
Ues it :)
$days = (strtotime($endDate) - strtotime($startDate)) / (60 * 60 * 24);
print $days;
Now its oKKKK
The following SO questions might be of some help: