Adding 30 minutes to time formatted as H:i in PHP

Posted by bateman_ap on Stack Overflow See other posts from Stack Overflow or by bateman_ap
Published on 2010-05-04T16:24:35Z Indexed on 2010/05/04 16:28 UTC
Read the original article Hit count: 132

Filed under:
|

Having a nightmare at the moment and just can't see why it isn't working

I have a value in the form H:i (ie 10:00, 13:30) etc called $time

What I want to do is create two new values, $startTime which is 30 mins before $time and $endTime which is 30 mins after $time

I have tried the following but just doesn't seem to want to work

$startTime = date("H:i",strtotime('-30 minutes',$time));
$endTime = date("H:i",strtotime('+30 minutes',$time));

If I pass through 10:00 as $time and echo out both $startTime and $endTime I get:

$startTime = 00:30
$startTime = 01:30        

© Stack Overflow or respective owner

Related posts about php

Related posts about strtotime