Issues with NSDate.

Discussion in 'iOS Programming' started by detz, Aug 10, 2010.

  1. detz
    Expand Collapse
    macrumors 65816

    Jun 29, 2007
    So here's the problem. I'm showing the user the date/time in local time so they see something like 5pm EST but the system stores it as: 2010-08-10 21:00:00 GMT, time zone = America/New_York (EDT) offset -14400 (Daylight)

    This has been fine up until now when I'm trying to add time to it and check to see if it's a new day. I'm basically adding an hour and if it's still the same day I do X otherwise do Y. The issue I'm having is since the time is GMT I'm getting to the next faster than I would normally. Take the data above.

    5pm + 5 hours is 10pm. 21:00 + 5 hours is the next day.

    Obviously not the same thing. Is there a way that I can make the system work in local time and not GMT? Is there a way I can pull the offset so at least I can put some logic in like 21:00 + 5 +offset?
  2. pflau
    Expand Collapse
    macrumors 6502

    Sep 17, 2007
    Work in GMT, and use localtime() to translate the result before and after.

Share This Page