增加30分钟的时差

时间:2018-06-13 09:54:05

标签: php codeigniter

时间是这种格式 - 09:00:00 - 这是09:30:00。然后我      需要      添加30分钟并将其存储在单独的变量中      动态。

Example:
$selectedTime = "9:00:00";
$endTime = strtotime("+30 minutes", strtotime($selectedTime));
echo date('h:i:s', $endTime);


output:
 9:00:00  to 9:30:00
 9:31:00  to 10:00:00
 10:01:00  to 10:30:00, etc

2 个答案:

答案 0 :(得分:0)

对此清除使用日期功能。

select concat(info, '_', side) as info_side, count(*)
from (
    select 
        info, side, 
        lag(info || side, 1, '') over (order by number) <> info || side as start_of_group
    from my_table
    ) s
where info = 'bar' and start_of_group
group by 1
order by 1;

 info_side | count 
-----------+-------
 bar_a     |     2
 bar_b     |     1
(2 rows)    
  

输出:09:30:00

答案 1 :(得分:0)

希望这会对您有所帮助: 使用$selectedTime = "9:00:00"; $endTime = date('H:i:s',strtotime('+30 minutes',strtotime($selectedTime))); echo $endTime; 来获得所需的结果:

工作演示:https://eval.in/1020357

strtotime

输出:

$previous_time = "9:00:00";
$endTime = strtotime("+30 minutes", strtotime($previous_time));

echo  $previous_time. ' To '.date('H:i:s', $endTime) ;

更多信息:http://php.net/manual/en/function.strtotime.php