hey well ive done a registration form and now i just want to add the registration date into the database ive tried setting the date to date variable like: $time = date("Y-m-d"); and then just put the $time into the sql statment but when i look at the time colum in the database it formats the date like 1981. does anyone have any other methods i could use ?
when store data in mysql you have to use proper value for more info review: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
To save time to mysql DATETIME field, you can either use "NOW()" in the query or $time = date("Y-m-d H:i:s"); - ads2help
The first parameter in the date() function specifies how to format the date/time. It uses letters to represent date and time formats. Here are some of the letters that can be used: d - The day of the month (01-31) m - The current month, as a number (01-12) Y - The current year in four digits An overview of all the letters that can be used in the format parameter, can be found in PHP Date reference
You should store time in your database in timstam format (Google for timestam) And when you want to display it, just call it from database and use your choice $t = gmdate('d-m-Y', $time) // Or use what format you like: Y-m-d,... PHP: Which $time is one you query from database Or want to store Y-m-d in your databse, try to Type of your column to varchar
Agreed. This is called the Epochtime. Storing dates this way, allows you to easily make calculations etcetera. Rgds, Carl