date formatting

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
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

date formatting

Post by crazytopu »

Hi guys

How can I use date function to send date,month and year to the database and store it in a date column?

Code: Select all

// year  month and day received from user input
echo $year;  
echo $month;
echo $day;


$post_date = date('Y,m,d');

$required_by = date('$year,$month,$day');  // I want to save it as the above date format

echo $required_by;
I get this long output -
$07eamWed, 14 Mar 2007 00:31:17 +0000,$03o33112,$14am07'
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You don't even need the date function for this unless the information you are writing is not in the proper forms already.

In addition, you have a single quote string. No variables are processed in single quote strings, hence the long and confusing result.
Post Reply