Jump to content


Photo

Take Away Dates.


  • Please log in to reply
1 reply to this topic

#1 ego0

ego0
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 27 August 2006 - 04:55 PM

Is it possible to take away two dates two be left with the difference between them to be displayed as a time (e.g) 2006,12,06 12:00 take away 2006,15,06 12:30

Would display the differnce as 3 days and 30 minutes?

Thanks

#2 jvalarta

jvalarta
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 27 August 2006 - 05:01 PM

Yes, use the mktime function to turn the dates into unix timestamps...do the math (subtract one from the other) then use date() and mktime() to format the time difference however you need.

http://php.net/mktime
http://php.net/date

$MyDate = '2006-08-01 10:30:45';
$diff = time() - mktime(substr($MyDate,11,2),substr($MyDate,14,2),substr($MyDate,17,2),substr($MyDate,5,2), substr($MyDate,8,2), substr($MyDate,0,4)); 
$DaysGoneBy = ($diff/86400);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users