Basically i need if it’s more than or equal to 45 minutes, it must be rounded up. if it’s less than that, it must be rounded down
Example :
- 18:12 needs to be 18:00
- 18:32 needs to be 18:00
- 18:45 needs to be 19:00
- 18:52 needs to be 19:00
- etc.
I’m not sure if that’s possible. really need your help, thanks
3
Answers
The best solution is probably using the Date function PHP has.
Also could be achieved with string functions but then you’ll need to account for midnight notations.
An explode approach could start with:
A regex approach could start with:
you can use function like this for 30 minutes
Solution with DateTime. Add 15 minutes and set minutes and seconds to 0.
As a complete test https://3v4l.org/mXBaU
Output: