Hi guys
I need to pull every time in 20 minutes intervals
I tried the code below but it is not working
$start="2010-03-03 11:40:00";
$end="2010-03-03 15:00:00";
for($i = $start; $i < $end; $i += 1 * 20 * 60){
echo"$i";
}
Hi guys
I need to pull every time in 20 minutes intervals
I tried the code below but it is not working
$start="2010-03-03 11:40:00";
$end="2010-03-03 15:00:00";
for($i = $start; $i < $end; $i += 1 * 20 * 60){
echo"$i";
}
php 5.3 goodness
foreach (new DatePeriod(new DateTime($start), new DateInterval('PT20M'), new DateTime($end)) as $dt) {
echo $dt->format('Y-m-d H:i:s'), "\
";
}
Kinda verbose though
You need to use strtotime() on $start and $end.
$start = strtotime("2010-03-03 11:40:00");
$end = strtotime("2010-03-03 15:00:00");
for($i = $start; $i < $end; $i += 1200){
echo date('Y-m-d H:i:s', $i) . '<br />';
}
Thanks guys