Is there a way of getting the next 15th minutes from given time?
For Example
- if input is
2021-08-26 12:00:37
then output should be2021-08-26 12:15:00
- if input is
2021-08-26 12:30:37
then output should be2021-08-26 13:15:00
CodePudding user response:
You can convert the date to a timestamp and then add it the equivalent of 15 minutes in seconds (15 * 60) and then convert it back to a date
CodePudding user response:
Use Carbon
It is installed by default in Laravel.
$date = Carbon::createFromFormat('Y-m-d H:i:s', '2021-08-26 12:00:37');
$newDate = $date->addMinutes(15)->format('Y-m-d H:i:s');