Combining separate date input elements into one date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Combining separate date input elements into one date

Post by edawson003 »

dob.gif
dob.gif (923 Bytes) Viewed 130 times
I would like to take user input in the above date field format and combine the date elements and post it to my mysql table. How can I set that up?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Combining separate date input elements into one date

Post by requinix »

date = YYYY + "-" + MM + "-" + DD

How much thought have you put into this?
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: Combining separate date input elements into one date

Post by edawson003 »

thanx for the info tasairis; however, if you think certain posts are too elimentary and not worth your time, I suggest next time don't bother responding.

This is more like what I was looking to get as a response

Code: Select all

 
<? $todo=$_POST['todo'];
if(isset($todo) and $todo=="submit"){
$month=$_POST['month'];
$dt=$_POST['dt'];
$year=$_POST['year'];
$date_value="$month/$dt/$year";
echo "mm/dd/yyyy format :$date_value<br>";
$date_value="$year-$month-$dt";
echo "YYYY-mm-dd format :$date_value<br>";
}
?>
 
More useful and less snarq!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Combining separate date input elements into one date

Post by requinix »

1. We don't like giving solutions. We give hints and clues and suggestions.
2. You didn't provide enough information for such a detailed answer as you wanted. How did I know what the fields were called? How did I know that the month field was going to give a zero-padded two digit number and not a month name? How did I know about this "todo" stuff?
3. It's spelled "snark".
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: Combining separate date input elements into one date

Post by edawson003 »

By the way, who's "we"? The Federation forum contributors? Of which, I'm guessing your the president...

And while your at it, correcting mispellings and such, you should go ahead and check your grammar.

Code: Select all

We give hints [color=#FF0000]and[/color] clues [color=#FF0000]and[/color] suggestions.
Correct:We give hints, clues and suggestions.

Thanks for playing!

P.S.
Check out: Eats, Shoots & Leaves: The Zero Tolerance Approach to Punctuation
by Lynne Truss

We of the the Snarqqq Society give this book two thumbs up.
Post Reply