[ create a new paste ] login | about

Link: http://codepad.org/SbFuqsXL    [ raw code | output | fork ]

PHP, pasted on Dec 12:
1
2
3
4
5
6
7
8
9
<?php
  $previous_date='20101202115755';
  $d = strptime($previous_date, '%Y%m%d%H%M%S');
  $prev_ts = mktime($d['tm_hour'], $d['tm_min'], $d['tm_sec'], $d['tm_mon'] + 1, $d['tm_mday'], $d['tm_year'] + 1900);
  
  $now = time();
  $diff = $now - $prev_ts;
  $diff = floor($diff / (60*60*24));
  echo 'Difference between ' . date('r', $prev_ts) . ' and ' . date('r', $now) . ': ' . $diff . ' days';


Output:
1
Difference between Thu, 02 Dec 2010 11:57:55 +0000 and Sun, 12 Dec 2010 10:17:21 +0000: 9 days


Create a new paste based on this one


Comments: