getdate() always returning 0 for the day? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

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?

SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
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?
[code]
$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'];
[/code]
Thanks for any help offered.

*EDIT*

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.
[code]
$Timestamp = mktime(0, 0, 0, ($CurMonth + 1), 1, $CurYear);
[/code]

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

Sign In or Register to comment.