View Single Post
Old 05-29-2008, 02:43 PM   #15 (permalink)
sketchMedia
The Frequenter
Advanced Programmer Top Contributor Good Samaritan 
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 469
Thanks: 26
sketchMedia is on a distinguished road
Default

I think this should do it, there is probably a better way of doing it but it works for me:

PHP Code:

$date 
'30-03-2008';
$date2 '31-03-2008';

//get the offset
$dateTime1 = new DateTime($date);
$dateTime2 = new DateTime($date2);
$dstZone = new DateTimeZone('Europe/London');//change accordingly

echo 'Difference: ',((strtotime($date2) + $dstZone->getOffset($dateTime2)) - (strtotime($date) + $dstZone->getOffset($dateTime1))) / 86400' Days'
outputs: 1 day.

edit: i think this is for php 5.2.x not sure about 5.1.x as i dunno when these classes were added, any1 know?
__________________
sketchMedia is offline  
Reply With Quote