anyone can tell how to add mins in php.?
i have values in Db in this format 00:10, 4:05 etc

i want to add mins...!!!

can anyone guide me little bit


7 Years
Discussion Span
Last Post by Froger93

Ideally you should store times and dates in the Unix timestamp method.

However you would need to create a function to split the time using the ':' character and then use the second part and figure out wether or not it is 59 if it is change it to 00 and then change the first part to the previous plus 1 etc.

function addMinute( $time ) {
    $part = explode( ":" , $time );
    if( $part[1] === 59 ) {
        $first = $part[0] + 1;
        $second = "00";
    } else {
        $first = $part[0];
        $second = $part[1] + 1;
    return $first . ":" . $second;

Thats just an example off of the top of my head.

   while($row = mysqli_fetch_row($result)) { ?>
        <td><?= $row[7]; ?></td>
            $current_time = '00:'.$row[7];
            $break_date = explode(':',$current_time);
            $timestamp = strtotime("$start_time");
            $etime = strtotime("+$break_date[0] hours $break_date[1] minutes $break_date[2] seconds", $timestamp).'<br>';
            $next_time = date('H:i:s', $etime);
            $start_time = $next_time;

$row[7] is a database value in min:sec format..!!
this code works well on windows but on linux server shows different output..!!

can anybody tell why php date functions works differently on different servers.?

Edited by sam023: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.