PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Einführung> <unixtojd
Last updated: Fri, 19 Jun 2009

view this page in

Datum und Uhrzeit



add a note add a note User Contributed Notes
Datum/Uhrzeit
zoe at monkeehouse dot com
24-Oct-2008 10:52
Should you want to convert between HH:MM:SS and plain seconds like in MySQL, these functions should do the trick:

<?php
function time_to_sec($time) {
   
$hours = substr($time, 0, -6);
   
$minutes = substr($time, -5, 2);
   
$seconds = substr($time, -2);

    return
$hours * 3600 + $minutes * 60 + $seconds;
}

function
sec_to_time($seconds) {
   
$hours = floor($seconds / 3600);
   
$minutes = floor($seconds % 3600 / 60);
   
$seconds = $seconds % 60;

    return
sprintf("%d:%02d:%02d", $hours, $minutes, $seconds);
}
?>

Einführung> <unixtojd
Last updated: Fri, 19 Jun 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites