<?php
$one = new DateTime('2012-01-24 13:00');
$two = new DateTime('2012-01-24 06:00');
$three = new DateTime('2012-01-24 08:42');
$four = new DateTime('2012-01-24 12:00');
$five = new DateTime('2012-01-24 06:33');
$array = array($one, $two, $three, $four, $five);
foreach($array as $a){
$a->modify("-7 hours");
echo $a->format('Y-m-d H:i') . "\n";
}
LIVE: http://codepad.org/JgoX3y7O
I would like show date without hours between 23:00-05:00. If date is in this range then should be doing minus without these hours.
My example show:
2012-01-24 06:00
2012-01-23 23:00
2012-01-24 01:42
2012-01-24 05:00
2012-01-23 23:33
but should be:
2012-01-24 06:00
2012-01-23 17:00
2012-01-24 19:42
2012-01-24 05:00
2012-01-23 17:33
$one and $four are OK, because 12:00-7:00 and 13:00-7:00 aren’t in range 23:00-05:00
How can i make it?
According from your comments I can only guess you’re tyring to “skip” a certain period of time. You should then be adding a ‘penalty’ for that amount of time, like: