What is the best way to create a date_created and date_modified in MySQL Database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the best way to create a date_created and date_modified in MySQL Database?

i am using xamp for my database. now my problems is, i want to make a column date_created and date_modified in my products. i used a relational database to do that but it so hard to query. date_info (table) date_id | date_today (columns) products (table) date_created | date_modified (columns) example there is record in date_info = (1 , 01-28-2017) (2 , 01-27-2017) then in products = (1 , 2 ) How can i query the actual date in the products instead of id. or there is another way to do that?

27th Jan 2017, 4:10 PM
Ivan Arnie Ranario
Ivan Arnie Ranario - avatar
4 Answers
+ 4
You can use JavaScript new Date() and just make a few new columns in your table. Then, INSERT INTO that column with your manipulated value of Date() for date_created. As for date_modified, UPDATE the table and SET date_modified with a new value everytime.
27th Jan 2017, 4:13 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
I don't know any other way. I'm sorry for being useless.
28th Jan 2017, 12:32 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
0
But what if i have a thousands of products. all of them has a date_created and date_modified, i think my application is take too long to load and my database is redundant because everyday i insert a record i also insert the current date for every products. i am concern in memory, the time to load the program and the data integrity of my database. By the way, thanks for your answer. I will do your suggestion for now.
27th Jan 2017, 10:53 PM
Ivan Arnie Ranario
Ivan Arnie Ranario - avatar
0
No. It's okay i will do your suggestion, it is also a good idea. thank you again
28th Jan 2017, 2:04 AM
Ivan Arnie Ranario
Ivan Arnie Ranario - avatar