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. Quote Link to comment 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"; Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
gspica Posted July 19, 2007 Author Share Posted July 19, 2007 That is working. Thanks so much. 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.