Support Forums
Time added to database - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Time added to database (/showthread.php?tid=4073)



Time added to database - Dutchcoffee - 12-30-2009

Hi,

Is it possible to fetch the time that a form was submitted to the database? When I submit my form to my database, it displays in a table - is it possible to display the time that it was added?

Let me know if I need to explain more.

Thanks


RE: Time added to database - Gaijin - 12-30-2009

Yes it is!
In your table you need to create an extra field, type "DATE" or "DATETIME" or "TIMESTAMP"
If you use time stamp you can create a field with this command
Code:
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,

The entry would look like, update_time = 2009-12-31 00:55:55

Or you can also use a PHP function "date()"

PHP Code:
$stamp date("Y.d.m H:i:s"); // TYPE: DATETIME
$stamp date("Y.d.m"); // TYPE: DATE
$stamp date("H:i:s"); // TYPE: TIME 

And just pass the $stamp along with other variables to your DB.