I have a time string in UNIX format . I need to round that string to closest interval of 30 minutes.
For eg: I have time as 9:20 AM than it should round it to 9:30 AM.
If minutes are greater than 30 like 9:45 AM it should round to 10:00 AM.
I have tried this so far:
$hour = date('H', $ltdaytmfstr);
$minute = (date('i', $ltdaytmfstr)>30)?'00':'30';
echo "$hour:$minute";
$ltdaytmfstr
is time string in unix format.
Any suggestions? It would be better if I can get the value returned in UNIX format .