Page 1 of 1

the num of week between two dates

Posted: Sun Oct 24, 2004 6:42 am
by lazerbri
hi
Im trying to get the number of weeks between two timestamps
and display it in a readable format like
12 weeks and two days

this is not as easy as I thought it would be?

can any one help

thanks
Brian

Posted: Sun Oct 24, 2004 7:38 am
by kettle_drum
Just use a bit of maths. Once you have got the time between in seconds you can then do something like:

Code: Select all

$time = '50000'; //some random time

$weeks = floor((60*60*24*7)/$time);
$time -= $weeks*(60*60*24*7);

$days = floor((60*60*24)/$time);
$time -= $days*(60*60*24);

$hours = floor((60*60)/$time);
$time -= $hours*(60*60);

$mins = floor(60/$time);
$time -= $mins*60;

$secs = $time;
Then output it as you wish.

thanks this is good stuff

Posted: Sun Oct 24, 2004 8:11 am
by lazerbri
thanks this is good stuff and it does the job

thanks
brian