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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:56:46+00:00 2026-06-18T03:56:46+00:00

I tried to convert String to date time and date time to string it’s

  • 0

I tried to convert String to date time and date time to string it’s working but some what error. I not getting correct formate.
my excepting result should be:
like this.02/02/2013 05:24PM
time should be 12 hours formate;

 NSString *dateTime = @"2013-02-02 15:54:31";
    int time=[[temp objectForKey:@"created"]intValue];
     NSLog(@"Time=%d",time);

    // Convert string to date object
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"YYYY-MM-DD HH:MM:SS"];
        [dateFormat setTimeZone:[NSTimeZone timeZoneWithName:dateTime]];
        NSDate *date = [dateFormat dateFromString:dateTime];
        NSLog(@"Nsdate=%@",date);

        // Convert date object to desired output format
        [dateFormat setDateFormat:@"hh:mma"];
        dateTime = [dateFormat stringFromDate:date];
        [dateFormat release];
        NSLog(@"DateTime=%@",dateTime);

    --------------------
    NSLogs :

     Time=2013
     DateTime=2013-02-02 17:06:09
     Nsdate=2013-01-02 11:30:00 +0000//it's not correct date
     DateTime=02/01/2013 05:00PM//it's not correct date and time// 
   ------------- 
    my excepting result should be like this:

    DateTime :02/02/2013 05:24PM 

If you have any idea please shear your ideas , It’s will help me.

  • 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-18T03:56:47+00:00Added an answer on June 18, 2026 at 3:56 am

    Change your this line

      [dateFormat setDateFormat:@"YYYY-MM-DD HH:MM:SS"];
    

    to

      [dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:SS"];
    

    mm and dd should be small

    Hope it helps you..

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

Sidebar

Related Questions

I am getting the Unable to convert MySQL date/time value to System.DateTime error because
I want to convert a string like 2012-03-08T00:00:00+01:00 into Date.. I tried to use
I tried many things but I always get cannot convert string to membershipuser from
I am using glibs functions to convert epoch time to string as follows. But
In PHP, how can I convert a date/time string in the format 20:13-02-05T13:45:17-0500 to
I am trying to convert a string date to the correct timezone value, I
String was not recognized as a valid DateTime error was occurred when I tried
I'm trying to convert std::string to float/double . I tried: std::string num = 0.6;
I've tried to convert bitrate mode from VBR to CBR with FFMPEG library,but bitrate
I am doing some exercises and tried to convert a simple class into a

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.