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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:03:42+00:00 2026-06-09T22:03:42+00:00

My string is something like this, 2012-12-08 17:00:00.0 . Now I am trying to

  • 0

My string is something like this, 2012-12-08 17:00:00.0. Now I am trying to retrieve date from this string by using NSDate formatter. My code is

NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-dd-MM hh:mm:ss"]; 
NSDate *date1 = [df dateFromString:@"2012-12-08 17:00:00.0"];
NSLog(@"%@ %@",date1);
[df release];

But all I am getting is null value alone..

I have tried several types to dateFormatter like, yyyy/mm/dd hh:mm:ss, YYYY-DD-MM HH:MM:SS.. but still no use.. Any suggestion will be appreciated.

  • 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-09T22:03:44+00:00Added an answer on June 9, 2026 at 10:03 pm

    Assuming that you have just put an empty string literal in the post by mistake and your actual dates are as described in your post, you need to use HH instead of hh to parse hours in 24-hour system. You also need to add .S to your format string to parse the last zero of your time string:

    NSDateFormatter *df=[[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-dd-MM HH:mm:ss.S"];
    //                 here -------^^       ^------ and here
    NSDate *date1 = [df dateFromString:@"2012-12-08 17:00:00.0"];
    NSLog(@"%@",date1);
    

    This produces the expected output (the difference in the hours is due to timezone difference):

    2012-08-12 21:00:00 +0000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I am just trying to insert string something like this 30/01/2012 into a
I have a string containing something like this Hello bla bla bla bla ok,
A Tcl nested String can be something like this: {abc {xyz foo {hello world}}}
I have something like this hard-coded: private string[,] m_RolesForUser = new string[,] { {John,President,Chair},
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
I'd like to do something like this String.concat '\n' [str1; str2 ... strn] so
I have written something like this pretty easily in C# ( string GetUrl(new {
I like to do something like this: public static List<string> ItemsOfEnum(T typeT) { List<string>
How I can do something like this in C++: void my_print(format_string) { vector<string> data;
I've never seen something like this before EntityA @Id long id @Column(name =field1) String

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.