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 797297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:46:56+00:00 2026-05-14T22:46:56+00:00

I have a stringdate 16-MAY-2010 23:04:44 which i need to convert to gmt time

  • 0

I have a stringdate 16-MAY-2010 23:04:44 which i need to convert to gmt time zone that is the out put required is 17-May-2010 12:03:03.

I used date formatters to convert but the result i am getting is not in the format i required.I am sending the code please let me know if i am doing correct or not

Here is the code:

NSString *timeStamp = [format stringFromDate:[NSDate date]];
NSString *output = [timeConv dateStringFromString:timeStamp];

- (NSString *)dateStringFromString:(NSString *)sourceString
{     
    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
    [dateFormatter setDateFormat:@"dd-MMMM-yyyy HH:MM:ss"];
    NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    [dateFormatter setTimeZone:gmt];
    NSDate *date = [dateFormatter dateFromString:sourceString];

    return [dateFormatter stringFromDate:date];
} 

The out put i am getting is the same old time without conversion. so please let me know the correct solution.

  • 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-14T22:46:57+00:00Added an answer on May 14, 2026 at 10:46 pm

    I know no cocoa whatsoever, but if I’m understanding your code correctly, you’re never telling the parser that your original string is not GMT, but rather GMT-1.

    Based on your own code (and again, with no knowledge of cocoa), this is what I believe you need to do:

    NSTimeZone *gmtminusone = [NSTimeZone timeZoneForSecondsFromGMT:-3600.0];
    [dateFormatter setTimeZone:gmtminusone];
    NSDate *date = [dateFormatter dateFromString:sourceString];
    NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    [dateFormatter setTimeZone:gmt];
    return [dateFormatter stringFromDate:date];
    

    If it doesn’t work right away, maybe it gives you the idea of what to do:

    1. Parse the string with a date formatter set to GMT-1, to output a date.
    2. Parse the date with a date formatter set to GMT, to output a string.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for example we have date May 12, 2010 <cfset may_12_2010 = CreateDate(2010, 5, 12)>
I have a string containing the UNIX Epoch time , and I need to
Folks, I have a string date which I can convert to numeric using: =DateValue(1/2/2011)
I have a string in the form MMM/dd/yyyy, ie. May/21/2010. Now I want to
I have entity class which is used to model a weather station, and it
I have a List which contains Dates : List<string> StringDates; [0]: 04.03.2010 [1]: 09.03.2010
I have a function that takes a string date in the format 08/24/2010 and
I need a function to check a date with boolean. I have a String
i have the code in c# string date = reader[date].ToString(); and got error that
I have result string date xml export from database like 2011-06-27T14:03:19.5300000+07:00. How to Convert

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.