Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6061205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:54:43+00:00 2026-05-23T08:54:43+00:00

First the code: NSString* dateTimeString = [NSString stringWithFormat:@%@%@, [aDictionary objectForKey:@date], [aDictionary objectForKey:@time]]; NSDateFormatter* dateFormatter

  • 0

First the code:

NSString* dateTimeString = [NSString stringWithFormat:@"%@%@", [aDictionary objectForKey:@"date"], [aDictionary objectForKey:@"time"]];

NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];    
[dateFormatter setDateFormat:@"yyyyMMddHHmm"];

NSDate* dsate = [dateFormatter dateFromString:dateTimeString];

dateTimeString string value is “201106242204”

however the dsdate gets incorrect value, in the debugger it shows: 2011-06-24 19:04:00 +0000

as you can see the hour should be 22 not 19. I have already wasted quite q bit of time on this. Tried setting the time zone, locale etc etc but nothing has any effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:54:44+00:00Added an answer on May 23, 2026 at 8:54 am

    Be aware that NSDateFormatter is locale-aware. This means that even if you specify a date format string, if the current locale on a device has a different format for the string you give it, it will override the string you provided the formatter. What is your UTC offset at your present location? Because NSDateFormatter always gives UTC time, if your offset is -6, it is giving you back the correct value, just in a different timezone. One of the features of NSDateFormatter I really don’t like. You might get the result you want by calling setTimeZone: on the date formatter.

    Try calling -descriptionWithCalendarFormat:timeZone:locale: on the parsed NSDate instance, passing your locale and timezone. I’m curious if it outputs your desired result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you check in code for the first time in Team Foundation Server?
Hi there I have this code NSLog(@%@,URLRequestQueryString); NSString *sendToServerString = [NSString stringWithFormat:@http://mydomain.co.uk/req.php%@,URLRequestQueryString]; NSURL *sendToServer
I often refactor code first by creating an inner class inside the class I'm
I'm a C# developer who's fumbling in the first VB code he's written since
For example, will the first piece of code perform a full search twice, or
First check out this code. I seems like it should work for me, but
I first got an error usign the code below, explaining that DataGridLinkButton' must be
First a little intro: Last year i wrote this http://dragan.yourtree.org/code/canvas-3d-graph/ Now, i want to
A bit of background first: I am using base code from a remote SVN
First, to make my job explaining a bit easier, here's some of my code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.