Quantcast
Channel: mysiteonline™ - Programming
Viewing all articles
Browse latest Browse all 15

Adobe AIR, SQLite, DATETIME, and weirdness.

$
0
0
Here I was, minding my own business, when I try to insert the current time in to a SQLite database via Adobe AIR. AIR has some internal mechanisms to actually give you an error if you don't insert the proper type in to an SQLite database (unlike SQLite itself, which will let you put anything in to any type of field - it just casts the values, from what I understand). Well, it sort of inserted the current time. SQLite has a shorthand insertion value for DATETIME fields when inserting the string value of "now". It will insert (you guessed it), the current time as it is NOW. When you view the "current" time, however...let's say the current date and time is: Tuesday, September 8th 2009 at 2:46:21pm EDT (that is 4 hours behind GMT). So when viewing the "current" time that you just inserted in to your SQLite database, you will see:
Tue Sep 8 2009 18:46:21 -0400 GMT

...what?

Okay, I get the military time, but, wouldn't that be 6pm? It's showing my timezone as EDT (-4 hours from GMT), so why is it listing 4 hours difference?!

Well, the answer basically is: I have no idea why it lists the timezone the way it does. If you want to insert your local time, you need to use the following:


The shorthand property of "now" can also be written as "DATETIME('now')", and the DATETIME method (in SQLite) apparently takes more than one parameter, and had I known what my issue was in the first place, it would have been easier to track down. You can find (as of September 8, 2009) SQLite's date and time methods at the following URL: SQLite Date and Time Functions.

Hopefully someone else doing a web search while grasping for straws might find this, and it'll help them out, rather than have them waste the better part of a day scratching their head, thinking of a workaround but knowing they must be missing something simple.

Viewing all articles
Browse latest Browse all 15

Trending Articles