J.D J.D - 10 months ago 98
PHP Question

MySQL datetime format

I am creating a registration page in HTML, PHP, and MySQL. I want to add a hidden field in the registration to be used as join date.

Is it better to have the hidden field containing the current date and time or assigning a variable the current datetime and using that in the SQL insert statement instead?

Anyways, if the following hidden form field is used, what would the date format be to store the datetime as

2010-07-06 07:55:12

<input name="joindate" type="hidden" id="joindate" value="<?php echo date(''); ?>">



 echo date('Y-m-d g:i:s',time()); //PHP

Our Better MySQL use datetime filed and call `NOW()

 INSERT INTO registration (Name,Date) VALUES ('Jarlsberg Cheese',NOW()) ;

In your SQL Statements

I hope this helps