Ima puno, nažalost ja nisam pronašao u manualu, niti na prvoj stranici na Googleu
Ovo time_diff sam siguran da ima neko riješenje, ali ono što me zanimalo je ovaj shift_span... tnx Mister
PHP kôd:
array(2) {
[0]=>
int(6)
[1]=>
int(3)
}
http://ideone.com/FR3x3
PHP kôd:
<?php
function shift_span($start, $end)
{
$time_diff = time_diff($start, $end);
$time_diff = $time_diff['hours'];
# ignore minutes, safe after we calculated difference
$start = (int) $start;
$end = (int) $end;
if($start + $time_diff <= 24)
return array($time_diff);
return array(
abs($end - $time_diff),
abs(($start + $time_diff) % 24)
);
}
function time_diff($start, $end)
{
# do not ignore minutes
$start = strtotime($start);
$end = strtotime($end);
$diff = abs($start - $end);
$hours = floor($diff / 3600);
$minutes = ($diff - ($hours * 3600)) / 60;
$hours = $start > $end? 24 - $hours: $hours;
return compact('hours', 'minutes');
}
$start = '18:00:00';
$end = '03:00:00';
var_dump(shift_span($start, $end));