'How to apply ceiling to a Unix timestamp in PHP?

I have a timestamp like 3:07:01 pm. Regardless of the number of seconds, I always need to round up this timestamp to 3:08:00 pm. How can I achieve this? I have tried using the ceiling function like so:

$time_rounded_up_to_nearest_minute = ceil(round(time() / 60) * 60);

but this function gives me some weird behavior around the 30 second mark. As soon as 30s mark hits it goes to the next minute, which is not what I want. I want it to always go to the nearest minute regardless of seconds



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source