ego0 Posted August 27, 2006 Share Posted August 27, 2006 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:30Would display the differnce as 3 days and 30 minutes?Thanks Link to comment https://forums.phpfreaks.com/topic/18816-take-away-dates/ Share on other sites More sharing options...
jvalarta Posted August 27, 2006 Share Posted August 27, 2006 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/mktimehttp://php.net/date[code]$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);[/code] Link to comment https://forums.phpfreaks.com/topic/18816-take-away-dates/#findComment-81157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.