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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:04:22+00:00 2026-06-15T03:04:22+00:00

i need to convert some date that i have in NSString to NSString in

  • 0

i need to convert some date that i have in NSString to NSString in this format: yyyy-MM-dd HH:mm:ss zzz
i write this code:

date input: date —> 27/03/2012

-(NSString *)setDateStringFormat:(NSString *)date 
 {
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
     [formatter setDateFormat:@"dd/MM/yyyy"];
     [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
     //[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
     NSDate *dateFormatted = [formatter dateFromString:date];

     [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
     [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
 return [formatter stringFromDate:dateFormatted];
 }

output: 2012-03-27 00:00:00 GMT

as you all can see i got the date in GMT and not in UTC
some one have an idea?

  • 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-06-15T03:04:24+00:00Added an answer on June 15, 2026 at 3:04 am

    try this method..

    -(NSString *)getUTCFormateDate:(NSString *)localDate
    {
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"dd/MM/yyyy"];
    
        NSDate *dateFormatted = [dateFormatter dateFromString:localDate];
        NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
        [dateFormatter setTimeZone:timeZone];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dateString = [dateFormatter stringFromDate:dateFormatted];
        [dateFormatter release];
        return dateString;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a date in this formart: Wdy, DD-Mon-YY HH:MM:SS GMT that I need
I need to convert some code done by someone else, to work in my
I have some data loaded as a np.ndarray and need to convert it to
I have just finished some code that is successfully filtering deadlines that fall between
I have this dilemma with JavaScript. I need to convert a list of dates
I have this query, that's been giving me some issues, it looks like this:
I have some JavaScript code that I'm trying to pass to my web service.
I need to convert some strings, and pull out the two first integers e.g:
I'm starting to develop applications using C++11 lambdas, and need to convert some types
My software is getting some strings in UTF8 than I need to convert to

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.