Jump to content

Take Away Dates.


ego0

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/18816-take-away-dates/#findComment-81157
Share on other sites

Archived

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

×
×
  • Create New...

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.