- Learn PHP The Easiest Way To Insert Time And Date Into Mysql Database Table
This Page Contains information about Learn PHP The Easiest Way To Insert Time And Date Into Mysql Database Table By wallpaperama in category MySQL with 0 Replies. , Last Updated: Tue Feb 07, 2023
Sat Apr 07, 2007
if you are asking yourself this question also, I may have the answer for you. I found the easiest way to enter or insert the time and date automatically into mysql is with the now() function. In this short simple tutorial guide i will show you steps to take to insert the time and date with the year month day hour and even seconds into a mysql database.
first make sure you have mysql database, if you don't have mysql on your website, you can visit our friends at www.webune.com and signup with one of their plans.
so, to insert the time and date inot my tables i use this sql query:
$sql = "INSERT INTO table-name(field_name) values (now())'";
if is do the query above, the system will enter a time stamp of "2007-04-04 21:48:37" which is right now..
you also have to make sure that you create the field correctly. you can use this table as and example:
CREATE TABLE `post`
`post_date` datetime NOT NULL default '0000-00-00 00:00:00',
I find that this is the best and easy way to inster the time and day of the current (present) year month day hour and seconds of today.