Simple, eh? -sigh-
A function. Two string arguments ( I guess it doesn't matter the type). Returning a string which is the time difference between the arguments. Think about it as a counter at your local CS internet-caffe.
function time_diff($start, $stop) {
...
return $diff;
}
echo "Your time playing CS: " . time_diff('19:37', '00:05') . ". Go home!";
I tried. Just too embarrassed to say how much time I've invested in this algorithm. I can't change the format (tell me abo开发者_如何学编程ut it!).
If you happen to know a class, a file or a piece of code from the depths of the internets, I'd be happy to make use of it.
"Thanks" you very much.
You can't do this correctly unless you know:
- The timezone.
- The day associated with those times.
Once you know that, you can do:
date_default_timezone_set('timezone here');
$seconds_diff = strtotime("2010-08-29 $end") - strtotime("2010-08-29 $start");
精彩评论