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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.