NSDateComponent giving me day incremented by 1

I know this is a time zone problem, but I don't know how to solve this.

I have a NSDate = 2013-07-29 01:10:01 +0000

When I do a NSDateComponent, the day component shows 28!

I'm in EST time zone right now, but why doesn't it just show 29 straight up?? Is this a bug?

If not, how do i fix this to show it properly? Or is it already proper?

Thanks.

Answers


The problem is that your calendar instance is currently set to your time zone, so it is interpreting the date as 5 hours prior to what it would be in GMT (which is what you pasted in your question).

To resolve this issue you should set the timeZone property on the calendar you are using to get the date components out of the date. Something like this will probably do the trick, assuming your calendar variable is named calendar:

calendar.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];

Need Your Help

Malformed Status line exception in J2ME

java-me ioexception httpconnection

I am getting Malformed Status line exception when requesting a service in J2ME for an NGINX server on S60 series nokia devices.

Swap content of 2 li's based on user selection

jquery swap

I'm trying to swap list item content. First I click on one li and then I click on another and swap their content. It works the first time I try to exchange them, but each time after, it swaps the l...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.