-1

Possible Duplicate:
How to find number of days between two dates using php
Days left - subscription expire?

I have code that should echo how many days has been from date (2012-10-01) to today.

$datetime1 = date_create('2012-10-01');
$datetime2 = date_create();

$day1 = date_format($datetime1, 'Y-m-d');
$day2 = date_format($datetime2, 'Y-m-d');    

$day = $day2 - $day1 / (60 * 60 * 24);
echo $day;

I cant get any right solution, so any ideas how I should do this?

Community
  • 1
  • 1
  • 3
    Check this out http://stackoverflow.com/questions/2040560/how-to-find-number-of-days-between-two-dates-using-php – mkey Oct 09 '12 at 13:04
  • You need to convert the dates to a unix timestamp prior to performing the calculation. – trickyzter Oct 09 '12 at 13:06

1 Answers1

0

Check this out Finding the number of days between two dates

Sample code (for your date) below:

$now = time();
$your_date = strtotime('2012-10-01');
$datediff = $now - $your_date;
echo floor($datediff/(60*60*24));
Community
  • 1
  • 1
mkey
  • 212
  • 1
  • 5