Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 14th, 2013  |  syntax: None  |  size: 0.99 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $previous_date='20101202115755';
  2. $current_date= date("YmdHis");
  3. $day_difference=?????
  4.        
  5. $day = 60*60*24;
  6.  
  7. $now = time();
  8. $target = strtotime('2010-12-24');
  9.  
  10. $diff = round(($target - $now) / $day);
  11. echo $diff;
  12.        
  13. $prev = DateTime::createFromFormat("YmdHis", '20101202115755');
  14. $curr = new DateTime();
  15. $diff = $curr->diff($prev);
  16. echo "Difference: ".$diff->days;
  17.        
  18. <?php
  19. $previous_date="201012021157552";
  20. $previous_date_as_time = mktime(
  21.   substr($previous_date, 8, 2),
  22.   substr($previous_date, 10, 2),
  23.   substr($previous_date, 12, 2),
  24.   substr($previous_date, 4, 2),
  25.   substr($previous_date, 6, 2),
  26.   substr($previous_date, 0, 4)
  27. );
  28.  
  29. $days_between_dates = (time() - $previous_date_as_time) / 86400;
  30.  
  31. echo $days_between_dates;
  32. ?>
  33.        
  34. $d = strptime($previous_date, '%Y%m%d%H%M%S');
  35. $prev_ts = mktime($d['tm_hour'], $d['tm_min'], $d['tm_sec'], $d['tm_mon'] + 1, $d['tm_mday'], $d['tm_year'] + 1900);
  36.        
  37. $diff = time() - $prev_ts;
  38.        
  39. $diff = floor($diff / (60*60*24)); // or round(), ceil() whatever fits best