http://www.perlmonks.org?node_id=545517


in reply to Re^2: Round time to nearest 15 or 30 minutes
in thread Round time to nearest 15 or 30 minutes

If you want the nearest 15 minute boundary, then the code is wrong. It will give you the previous 15 minute boundary.

You need to:

Note that the modulus operator % only works with integers. In practice, you can probably ignore the fraction of a minute that gets thrown away. If you can't, then you'll need to write your own remainder function.