time - Difference between timestamps PHP decimal format -


im trying difference between timestamps in php.

for instance have login time

  $login = "2014-11-24 13:45:00";   $current_time = date('y-m-d h:i:s');  // lets pretend 2014-11-24 14:50:00 

i want compare login time current time, , show in 2 formats

the obvious display have this. showing difference.

  01:05:00 // time difference 

but want have in decimal format calculations. how can convert above 'difference' decimal display.??

  1.083  // in case 1:05 difference calculates 1.083 in decimal  

more examples...

 00:30:00 // half hour difference  0.5 // decimal   00:45:00 // 45 minutes  0.75 // decimal   03:14:00 // 3 hours 14 minutes  3.23 // decimal 

  $login = strtotime("2014-11-27 01:00:00");   $current_time = time();   echo "difference in hours: ". ($current_time-$login)/3600; 

simple :)

fiddle


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -