rashmi_k28 Posted March 5, 2008 Share Posted March 5, 2008 Hi, How to reduce the timestamp from 2008-03-05 10:00:01 to 2008-03-04 10:00:01. The timestamp should be divided like 2008-03-05 10:00:01,2008-03-05 09:50:01,2008-03-05 09:40:01... and so on Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted March 5, 2008 Author Share Posted March 5, 2008 list($year,$month,$day,$hour,$minute,$second) = explode(':', date('2008:03:05:09:50:01')); $minute = 10*(floor($minute/10)); $time_interval = array(); for($minutes=0; $minutes<=24*60; $minutes += 10) { $ti = date('H:i', mktime($hour,$minute-$minutes)); //array_reverse($time_interval); //array_reverse($time_interval); array_push($time_interval,$ti); } //array_pop($time_interval); for($i=0;$i<count($time_interval);$i++){ print $time_interval[$i]."\n"; } I have tried the code but now I want the $time_interval array to be reversed. But the array is not reversed if I add array_reverse($time_interval); Please tell me hot to reverse the array Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 array_reverse does work. You seem to have it commented out though. Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted March 5, 2008 Author Share Posted March 5, 2008 If I uncomment also proper result is not got. So I have commented it Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 Try calling the function properly then $minute = 10*(floor($minute/10)); $time_interval = array(); for($minutes=0; $minutes<=24*60; $minutes += 10) { $time_interval[] = date('H:i', mktime($hour,$minute-$minutes)); } array_reverse($time_interval); foreach($time_interval as $val){ print $val."\n"; } Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted March 5, 2008 Author Share Posted March 5, 2008 12:20 12:10 12:00 11:50 11:40 11:30 11:20 11:10 11:00 10:50 10:40 10:30 10:20 10:10 10:00 09:50 After adding arr_reverse also 12:20 12:10 12:00 11:50 11:40 11:30 11:20 11:10 11:00 10:50 10:40 10:30 10:20 10:10 10:00 09:50 No change in the values. Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 Sorry, should've tested my code... $res = array_reverse($time_interval); foreach($res as $val){ print $val."\n"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.