Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good to store date in INT(milliseconds) format rather than yyyy-mm-dd hh:mm:ss format?

I have one questions regarding storing date in mysql database. Here is it :

Is it good to store date in INT(milliseconds) format rather than yyyy-mm-dd hh:mm:ss format?

So for example, at a time of writing question, the datetime is 2016-02-05 12:19:46. Is it good idea to store this datetime in database in INT means millisecond (1446xxxxxxx) format? Will it increase my db performance?

like image 688
Chintan Panchal Avatar asked Sep 01 '25 17:09

Chintan Panchal


1 Answers

No, it's not good practice to store date in integer format(milliseconds). Because whenever you'll need date from database you've to convert it back into Date Format and it'll affect your application's performance. And When talking about Db's performance it'll be constant as there wouldn't much affect but it'll be a bottle neck for you to retrieve date from database and convert back to date format and represent or use in your application.

But you can do it if you're in really need of it. As i'm unknown to your scenario of application and it's usage.

like image 158
Amulya Kashyap Avatar answered Sep 05 '25 10:09

Amulya Kashyap