Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
getdate() always returning 0 for the day?
Alright, I am trying to get the day of the week that the month started on so I can produce a PHP-based calendar for a site I am developing. For some reason however, "getdate()" is always forcing "wday" to zero. It's driving me insane because after hours of searching, I have come across several other calendars that use the exact same code that I use and they work. I don't get why this is happening, could somebody explain this, or is it another PHP anomaly?
$CurMonth = (date("n") - 1);
$CurYear = date("Y");
$Timestamp = mktime(0, 0, 0, $CurMonth, 1, $CurYear);
$MaxDay = date("t", $Timestamp);
$ThisMonth = getdate($Timestamp);
$StartDay = $ThisMonth['wday'];
Thanks for any help offered.
I figured it out. Apparently the "mktime()" function in PHP doesn't adhere to regular coding practices, and the month range is 1-12, not 0-11. I modified the code as shown below and it works properly now.
$Timestamp = mktime(0, 0, 0, ($CurMonth + 1), 1, $CurYear);
0 · ·