jasonc Posted October 31, 2009 Share Posted October 31, 2009 for ($r=1; $r <= 12; $r++) { echo(":" . date('F', mktime(0, 0, 0, $r, 0, 0)) .":"); } produces :December::January::February::March::April::May::June::July::August::September::October::November: when it would seem it should be :January::February::March::April::May::June::July::August::September::October::November::December: in month/number order ?! is there something wrong with this function or is there something wrong with my code ? Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/ Share on other sites More sharing options...
Mchl Posted October 31, 2009 Share Posted October 31, 2009 Give it a year different from 0 Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/#findComment-948496 Share on other sites More sharing options...
salathe Posted November 1, 2009 Share Posted November 1, 2009 There is nothing wrong with using year 0 (it equates to 2000). The problem is using day 0: a month starts with day 1 and 0 means the last day of the previous month. Just change the day parameter from 0 to 1. Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/#findComment-948628 Share on other sites More sharing options...
Mchl Posted November 1, 2009 Share Posted November 1, 2009 As usual I mixed up which goes first. Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/#findComment-948640 Share on other sites More sharing options...
jasonc Posted November 2, 2009 Author Share Posted November 2, 2009 thanks for that it works now i have taken out all the ending parts of the date that were not needed. just used... echo(":" . date('F', mktime(0, 0, 0, $r)) .":"); instead thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/#findComment-949779 Share on other sites More sharing options...
salathe Posted November 3, 2009 Share Posted November 3, 2009 Be warned that by missing the $day parameter out, it will assume the current day. When it comes to the end of a month (anything after the 29th) you'll run into trouble since there is no 30th of some months (february will suffer even more). For example, if today was the 31st then the list of months would be :January::March::March::May::May::July::July::August::October::October::December::December:. Best just stick a 1 into the $day parameter. Quote Link to comment https://forums.phpfreaks.com/topic/179775-solved-mktime-show-months-in-order-but-starts-with-december-not-january-with-month-1/#findComment-949839 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.