Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Blog Reader iPhone App Adapting Data for Display Formatting Dates with NSDateFormatter

my current time is different to what it shows on the nslog and the computer clock?

Hi,

For some reason I'm seeing different time on the NSLog and the computer clock.

They both got the same date, minutes and seconds, but the hour is wrong. They must have different region selected...

How do I fix this?

1 Answer

Nathan Tallack
Nathan Tallack
22,159 Points

If you have a object instantiated from the [NSTimeZone systemTimeZone], it will be cached by the application and will not reflect the current device's zone until you clear it using [NSTimeZone resetSystemTimeZone].

Use [NSTimeZone localTimeZone] instead of [NSTimeZone defaultTimeZone] if you want your timezone variable to reflect any updates to the application's timezone.

NSTimeZone *timeZone = [NSTimeZone localTimeZone];

Click here for more info.

Cheers Nathan!