This question already has an answer here:
I need to round the actual date/time to nearest past 15 min. and calculate the 10 previous 15 min times.
For ex. 12/07/2014 16:25 should be rounded to 12/07/2014 16:15 and i must retrieve 12/07/2014 16:00, 15:45, 15:30, etc... It must keep track of hour,day,month, year/leap year. I need all variables year/month/day/hour/minutes.
What is the easiest way to do that ? php or javascript ? any working script ?
I scratching my head...
</div>
You can try something like this
$currentDT = new \DateTime('2011-12-13 14:15:16');
print_r($currentDT);
echo '</br>';
$filterRange = new \DateInterval('PT15M');
$filterDate = clone $currentDT;
$filterDate->sub($filterRange);
print_r($filterDate) ;
Output:
DateTime Object ( [date] => 2011-12-13 14:15:16 [timezone_type] => 3 [timezone] => Europe/Berlin )
DateTime Object ( [date] => 2011-12-13 14:00:16 [timezone_type] => 3 [timezone] => Europe/Berlin )