Hi,
I just want the code to check whether the value in database for that timestamp is present or not. If it is present then array_push that value else store 0.
$timeincr=10;
$graphincr = 5;
$time_interval = array();
for($i=0;$i<24;$i++){
if($i<10){
$hour = "0".$i;
}
else{
$hour = $i;
}
for($j=0;$j<60;$j=$j+$timeincr){
if($j==0){
$item = $hour.":00";
array_push($time_interval,$item);
}
else{
$item = $hour.":".$j;
array_push($time_interval,$item);
}
}
}
$dbvalue = getvalue();
array_shift($dbvalue);
$last_date = $dbvalue[0];
array_shift($dbvalue);
list($dtstr,$last_time)= split(" ",$last_date,2);
$last_time = substr($last_time, 0,5);
list($last_timehr,$last_timemin) = split(":",$last_time,2);
$cnt=0;
$time_val[0]="00:00";
$sublast_date = substr($last_time, 0,4)."0";
while($time_val[$cnt] <= $sublast_date){
$cnt++;
$time_val[$cnt] = $time_interval[$cnt];
}
This code is for 0th hour of current day to 24hours.
So Similarly for the last 24hours I need the code like this.
But how to decrement based on the current hour for one day