PDA

View Full Version : Time through forms through to SQL


bensonfactor
10-10-2002, 12:52 AM
Currently I have a form that submits some data into a database, I need to find a way that the form, using a hidden field can submit a current time into a datetime field.

Velocd
10-10-2002, 03:00 AM
Let's suppose your date-time field is called dateline, located in table data_table. This is what the query should look like:


$DB_site->query("INSERT INTO data_table (dateline) VALUES ('".time()."')");


That will submit the current time of whatever was processed into the database. It will be stored in the database as a timestamp, therefore you'll need to convert it to a readable format when retrieving it from the database.

Here is how to do that quickly, after you use the SELECT query, just follow this example:


$date = $query_array['dateline'];
$today = vbdate("Y-m-d",$date);


And $today is your variable to use. Hope any of this helps ;)