Pogledajte određenu poruku
Staro 12. 04. 2012.   #3
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

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 $end24 $hours$hours;
    
    return 
compact('hours''minutes');
}
 
$start '18:00:00';
$end '03:00:00';
 
var_dump(shift_span($start$end));
__________________
Github // LinkedIn // PHP // ZCE // Stackoverflow PHP // Site5 Web Hosting

Poslednja izmena od webarto : 12. 04. 2012. u 23:15.
webarto je offline   Odgovorite uz citat