Ahh, that makes a lot more sense. Now, when you say "always use UTC" (which makes more sense to me), how exactly would I convert a time to a different timezone? In my original question I asked "How would I go about converting a string like "8-8-2010 11:00 AM EST" into the proper format for sqlite3?" Can you provide some sample code or a page that would show how to do this?
I come from a .NET background and usually dealing with datetime stuff is simple, so excuse me for asking so many questions :) Bara On Aug 9, 12:03 am, Sarwar Erfan <[email protected]> wrote: > In my previous reply, by 'current time' I meant your local time (your > time zone seems to be GMT-4) > > So, when you are getting UTC (GMT) using select DATETIME('NOW') -- it > is 4 hours advanced. > To get the time in your own timezone (the timezone set in the device), > you need to use the extra parameter 'localtime' > > If you are planning to save time in database for later use, you better > save the timezone also. Or, always use UTC. Because, if for some > reason the user changes the timezone of the device, then all your > saved time (without timezone) will become wrong. If your app does > something based on current time and some other time record previously > saved in database --- it will be a problem. > > Once you have the time in your application, you can change the > timezone (if required) in code. > > Regards > Sarwar Erfan > > On Aug 9, 9:51 am, Sarwar Erfan <[email protected]> wrote: > > > > > select DATETIME('NOW') returns UTC or Coordinated Universal Time > > > select datetime('now','localtime') returns the current time. > > > Regards > > Sarwar Erfan > > > On Aug 9, 9:08 am, Bara <[email protected]> wrote: > > > > Hello all, > > > > I'm a bit confused as to how to handle different timezones when saving > > > datetimes to the local database in Android. > > > > When I do a SELECT DateTime('now') in the sqlite3 database created by > > > Android, it says "2010-08-09 03:07:19" but my current time is actually > > > "2010-08-08 23:07:19" (eg: 4 hours earlier). Why is that? Does that > > > mean I need to add 4 hours to all datetimes so they match the sqlite3 > > > timezone? > > > > For example: How would I go about converting a string like "8-8-2010 > > > 11:00 AM EST" into the proper format for sqlite3? > > > > Bara -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

