adamhhh Posted March 13, 2007 Share Posted March 13, 2007 is there a way to do this? e.g. i have three drop down boxes in html asking the user for day (1-31), month, year (2007 or 2008) i then have // get user input $start_day = $_POST["start_day"]; $start_month = $_POST["start_month"]; $start_year = $_POST["start_year"]; //echo $start_year; $the_date = $start_day . "/" . $start_month . "/" . $start_year; echo $the_date; say then i get an output as 13/10/2007 if the user enters that date, is there a way to get what day of the week this is? Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/ Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 I think, and I am going to try and test this, but this may work: $timestamp = mktime ($start_month, $start_day, $start year); $day = date('l', $timestamp); echo "$day"; edit: tested and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206255 Share on other sites More sharing options...
adamhhh Posted March 13, 2007 Author Share Posted March 13, 2007 hmm still trying to get that to work, its telling me every day is tuesday at the moment what does the 1 stand for? Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206263 Share on other sites More sharing options...
ted_chou12 Posted March 13, 2007 Share Posted March 13, 2007 how about: <?php $timestamp = strtotime("$start year-$start_month-$start_day"); $day = date('l', $timestamp); echo "$day"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206265 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 The "1" is an "l" Lower Case L. Actually, you're right about the day though. Something is telling it to only check with today's date. The lowercase L tells the date function to display the day of the week, full word. Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206268 Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 Yay, ted's method worked. I guess it was the mktime that was setting it to today's date? Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206269 Share on other sites More sharing options...
adamhhh Posted March 13, 2007 Author Share Posted March 13, 2007 thanks for your help guys, i used $new_date = date("l", mktime(0, 0, 0, $start_month, $start_day, $start_year)); in the end which works great. Quote Link to comment https://forums.phpfreaks.com/topic/42510-solved-getting-day-of-week-from-user-defined-date/#findComment-206277 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.