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

Thanks

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.

<?php
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.

<?php
   while($row = mysqli_fetch_row($result)) { ?>
   <tr>
        <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;
   ?>
        </tr>
       <?}?>

$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.?

Because it's supposed to use a UNIX time stamp or a Linux timestamp.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.