Jump to content

date function


mindapolis

Recommended Posts

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
Share on other sites

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
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.