Hi All,
I want to be able to add the current date and time into a mysql table at the time a form is submitted.
I will then need to be able to retrieve this information and display it in the admin panel I am designing.
Can someone show me how I can achieve this, including the format I wuld need for the mysql column.
Thanks
inserting/retrieving current date and date of form submissio
Moderator: General Moderators
mysql supports a field type called timestamp which will set the date and time of when the record was last updated.
to retrieve the date/time you will need to use date_format() in your select statement.
should return 30 11 2004 12 11 31
or day, month, year, hour, minute, second
http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html
and look for date_format
to retrieve the date/time you will need to use date_format() in your select statement.
Code: Select all
SELECT id, date_format(yourDateField, '%d %m %Y %h $i $s) FROM yourTableName;or day, month, year, hour, minute, second
http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html
and look for date_format
-
I always need the timestamp provided by php in my scripts, that's why I never use mysql-timestamps. You can get the actual time(-stamp) with $timestamp = time();
(http://www.php.net/manual/en/function.time.php)
and insert that with your according data of the submitted form.
djot
-
I always need the timestamp provided by php in my scripts, that's why I never use mysql-timestamps. You can get the actual time(-stamp) with $timestamp = time();
(http://www.php.net/manual/en/function.time.php)
and insert that with your according data of the submitted form.
djot
-
and offcourse, mysql has it's own set of nice date-and-time functions.
http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html
my favorites: now, dateformat, from_unixtime, unix_timestamp
http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html
my favorites: now, dateformat, from_unixtime, unix_timestamp