t_machine Posted June 6, 2009 Share Posted June 6, 2009 Hi, how can I list the days in the current month? It should account for months with 31, 29, 28, 30 days. 1,2,3,4.... Quote Link to comment https://forums.phpfreaks.com/topic/161202-how-to-list-days-in-current-month/ Share on other sites More sharing options...
Daniel0 Posted June 6, 2009 Share Posted June 6, 2009 $time = mktime(0, 0, 0, $month, 1, $year); $numDays = date('t', $time); foreach (range(1, $numDays) as $day) { echo $day; } Or if you want a one-liner: echo join(', ', range(1, date('t', mktime(0, 0, 0, $month, 1, $year)))); Quote Link to comment https://forums.phpfreaks.com/topic/161202-how-to-list-days-in-current-month/#findComment-850608 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.