mindapolis Posted April 26, 2011 Share Posted April 26, 2011 How would you use the date function to display a birthday with an user's input? Link to comment https://forums.phpfreaks.com/topic/234789-date-function/ Share on other sites More sharing options...
cunoodle2 Posted April 26, 2011 Share Posted April 26, 2011 What format is the user's input in and what format would you like to display it in? Link to comment https://forums.phpfreaks.com/topic/234789-date-function/#findComment-1206620 Share on other sites More sharing options...
mindapolis Posted April 26, 2011 Author Share Posted April 26, 2011 Here's part of the form will fill out and I need it in a MM-DD-YYYY format. When is your birthday? <Select name = "month" value = "<?php echo $_POST[date]; ?>" > HEREDOC; $month=array('January' , 'February' , 'March' , 'April' , 'May', 'June', 'July' , 'August', 'September' , 'October' , 'November' , 'December'); foreach ($month as $value){ print "<option value =\"$value\"> $value </option>\n"; } echo "<select name = \"day\"> \n"; for ($day =1; $day <=31; $day ++) { print "<option value =\"$day\"> $day </option>\n"; } echo <<<HEREDOC <select name = "year"> <br /> HEREDOC; for ($year=2011; $year >=1993; $year--) { print "<option value =\"$year\">$year </option>\n"; } echo <<<HEREDOC Link to comment https://forums.phpfreaks.com/topic/234789-date-function/#findComment-1206645 Share on other sites More sharing options...
cunoodle2 Posted April 27, 2011 Share Posted April 27, 2011 Please enclose your code in the "code" tags.. <?php $i = 1; $month=array('January' , 'February' , 'March' , 'April' , 'May', 'June', 'July' , 'August', 'September' , 'October' , 'November' , 'December'); foreach ($month as $value){ print "<option value =\"$i\"> $value </option>\n"; $i++; } echo "<select name = \"day\"> \n"; for ($day =1; $day <=31; $day ++) { print "<option value =\"$day\"> $day </option>\n"; } echo <<<HEREDOC <select name = "year"> <br /> HEREDOC; for ($year=2011; $year >=1993; $year--) { print "<option value =\"$year\">$year </option>\n"; } echo <<<HEREDOC ?> Then on the next page just do.. <?php echo $i."-".$day."-".$year; ?> Link to comment https://forums.phpfreaks.com/topic/234789-date-function/#findComment-1206999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.