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. Link to comment https://forums.phpfreaks.com/topic/113483-solved-returing-the-day-of-a-date/ 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. ?> Link to comment https://forums.phpfreaks.com/topic/113483-solved-returing-the-day-of-a-date/#findComment-583101 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); Link to comment https://forums.phpfreaks.com/topic/113483-solved-returing-the-day-of-a-date/#findComment-583102 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. Link to comment https://forums.phpfreaks.com/topic/113483-solved-returing-the-day-of-a-date/#findComment-583107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.