Jump to content

Archived

This topic is now archived and is closed to further replies.

ego0

Take Away Dates.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

[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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.