gspica Posted July 19, 2007 Share Posted July 19, 2007 I have an array of time/dates - $timedate[] I need to apply mktime to each time\date in the array $timedate[0] = 00,00,00,05,20,2003 $timedate[20] = 00,00,00,11,03,2004 When I attempt to run mktime against $timedate[0] and $timedate[20] I get the same result mktime($timedate[0]) = 1184831045 mktime($timedate[20]) = 1184831045 if I run mktime(00,00,00,05,20,2003) = 1053414000 mktime(00,00,00,11,03,2004) = 1099465200 Why is this? And how can I convert these to mktime. I am pulling the dates from a mysql database. Link to comment https://forums.phpfreaks.com/topic/60851-solved-apply-mktime-to-an-array-of-timedates/ Share on other sites More sharing options...
Carterhost Posted July 19, 2007 Share Posted July 19, 2007 Try using Quotes? $timedate[0] = "00,00,00,05,20,2003"; $timedate[20] = "00,00,00,11,03,2004"; Link to comment https://forums.phpfreaks.com/topic/60851-solved-apply-mktime-to-an-array-of-timedates/#findComment-302773 Share on other sites More sharing options...
chigley Posted July 19, 2007 Share Posted July 19, 2007 Why are you using mkdir()? <?php $originals = array("00,00,00,05,20,2003", "00,00,00,11,03,2004"); $timestamps = array(); foreach($originals as $k => $v) { $pieces = explode(",", $v); $timestamps[$k] = mktime($pieces[0], $pieces[1], $pieces[2], $pieces[3], $pieces[4], $pieces[5]); } // $timestamps[0] = 1053414000 // $timestamps[1] = 1099465200 ?> Maintains original array keys in the output array Link to comment https://forums.phpfreaks.com/topic/60851-solved-apply-mktime-to-an-array-of-timedates/#findComment-302775 Share on other sites More sharing options...
gspica Posted July 19, 2007 Author Share Posted July 19, 2007 That is working. Thanks so much. Link to comment https://forums.phpfreaks.com/topic/60851-solved-apply-mktime-to-an-array-of-timedates/#findComment-302800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.