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

  • SEARCH
  • Home
  • 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 6368563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:41:31+00:00 2026-05-25T00:41:31+00:00

My application grabs a date / time from a remote server which is alway

  • 0

My application grabs a date / time from a remote server which is alway in GMT +1 (UTC/GMT +1 hour) timezone.

The format the server is providing is :

24 08 2011 08:45PM

I would like to convert this time stamp into the equivalent time/date of the users time zone (the user can be anywhere in the world).

thus as an example :
24 08 2011 08:45PM coming from the server should be presented

24 08 2011 09:45PM to an Italian user (rome) (GMT + 1)

This code works on some timezones but i have a bad feeling that there is something very wrong about it and that there is a much more elegant way to do it

NSString *dateString = @"24 08 2011 09:45PM";
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
     [dateFormatter setDateFormat:@"dd MM yyyy hh:mma"];
    NSDate *dateFromString = [[[NSDate alloc] init] autorelease];
    dateFromString = [dateFormatter dateFromString:dateString];


    NSDate* sourceDate = dateFromString;
    NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"BST"];
    NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];
    NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
    NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
    NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
    NSDate* destinationDate = [[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate] ;
    NSString *thePubDate =  [dateFormatter stringFromDate:destinationDate];//[appLogic getPubDate];
    NSLog(@"Result : %@",thePubDate);
    [dateFormatter release];
    //[dateFromString release];
    [destinationDate release];

I will appreciate your thoughts and suggestions on the matter

  • 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-25T00:41:32+00:00Added an answer on May 25, 2026 at 12:41 am

    Just set the timeZone in the dateFormatter, This code is enough

    NSString *dateString = @"24 08 2011 09:45PM";
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd MM yyyy hh:mma"];
    NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"BST"];
    [dateFormatter setTimeZone:sourceTimeZone];
    NSDate *dateFromString = [dateFormatter dateFromString:dateString];
    

    The dateFromString will now have the date 24 08 2011 08:45PM(GMT).. Then to convert this to string with local time just code the following,

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd MM yyyy hh:mma"];
    NSString *stringFromDAte = [dateFormatter stringFromDate:dateString];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application which grabs some data from an external XML source.
In the university we must develop an android application, which grabs our marks from
I've got a PHP application which needs to grab the contents from another web
Well, in my application there is textfield, which contains some date. Textfield is not
I am building a ruby application that grabs emails sent to a server and
I am currently working on a PHP application which is ran from the command
I have an application that grabs a snapshot of another desktop. This process is
Application frameworks such as DotNetNuke, Eclipse, Websphere and so forth are available today which
Application is asp.net MVC. I want to put a textbox for date using mask.
Imagine a document window in a MDI application which contains a child WPF window,

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.