- Forums
- MYSQL
- Best Way To Set Date In Mysql
What Is The Best Way To Set Date In Mysql? Is Easy, We Are Going To Show You The Best Way To Setting Dates In A Database Using Mysql And Php [2308], Last Updated: Mon Jun 24, 2024
Webune Support
Mon Oct 19, 2009
0 Comments
553 Visits
Hi,
Welcome to Webune Support Forums - We teach you good stuff!!!!
today we are going to teach you the best way to enter data format in MySQL database using php.
We've found that the best way to enter the date in your databases is by using PHP's function: time()
this functions works better than the date() functions.??
why, because, the time() function enters sequenced unique numbers even to the last second.
so if you are thinking about putting time into your database, its best to use the time() function.
but how else do you learn best? you learn by doing, ,right. so i am going to give you an example php code you can use to see how you can set date into MySQL table, use this query for example
PHP CODE:
$query = "INSERT INTO blogs SET date=".time();
as you can see, using MySQL, you can set the current date. the time() function is useful in php/MySQL to add data in any MySQL table, some advantages are that you can change the date format let on as you edit or modify your rows. with the time() function, you can even add days as dates or just display the day, month, year, even the mintues or seconds. its very helpful when you put data into a MySQLand add days in the date because you can set date sql as your format using a simple function . there are some MySQL system scripts you can buy to enter the time zone, but why spend money when you can create the code yourself using php and MySQL to insert custom dates in any MySQL database with the example above using set the value. so try it yourself, you will see its easier to manage and compatible with many standard input.