Solarpitch Posted July 6, 2008 Share Posted July 6, 2008 Hi, I am currently assigning the date in the format of (mdy) to the variable $date. Want I want to do is check if the day is a Sunday. So far I have... <?php $d=date(N); if ($d=="7") { //do something... } ?> but this just checks todays day. I want to check the day of a specific date. So if the user selects a date 3 months in the future I want to see if that date falls on a Sunday. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 6, 2008 Share Posted July 6, 2008 Try: <?php $date = "07-07-2008"; echo date('l',strtotime($date));//using l will save you the stack of if statements -- it returns the day for you. ?> Quote Link to comment Share on other sites More sharing options...
strayduck Posted July 6, 2008 Share Posted July 6, 2008 If you use mktime() to take your desired date and turn it into a Unix timestamp, you can use the date() function in the same way you do now but pass it the timestamp you just made with mktime (as, if you don't give date a timestamp to parse, it will assume you want the current timestamp) $userdate = mktime($hour, $minute, $second, $month, $day, $year); Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 6, 2008 Author Share Posted July 6, 2008 Thanks for that guys. I tried your example GingerRobot and it works fine for what I need. 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.