Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing the Date and Time in a SQL Database on Android

I'm attempting to store 3 values in a database I've created on an android device. The values are NAME, DATE, and TIME. My question is thus: what is the best approach to fetch and store the current DATE and TIME values when they are inserted into the database?

So far I have identified two ways to do this, either by making system calls in android like //values.put(TIME, System.currentTimeMillis()); or using SQL functions like GETDATE(). But, which is better?

If I'm heading off in the wrong direction, please let me know and direct me towards the right direction.

like image 902
Jevarlo Avatar asked Nov 26 '25 20:11

Jevarlo


1 Answers

Using the SQL functions will be more compatible with other tools using the same SQL engine.

Using text in ISO format YYYY-MM-DD hh:mm:ss.fff will be widely compatible and still sort properly.

like image 78
Doug Currie Avatar answered Nov 28 '25 15:11

Doug Currie