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 Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/ 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 Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483596 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. Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483598 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 Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483652 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"; } Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483662 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. Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483665 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"; Link to comment https://forums.phpfreaks.com/topic/94420-timestamp/#findComment-483666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.