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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:33:17+00:00 2026-06-01T14:33:17+00:00

I have a date in NSString format with this content: 29/02/2012 12:00:00 AM I’m

  • 0

I have a date in NSString format with this content: 29/02/2012 12:00:00 AM

I’m trying to convert it to NSDate object in order to make comparisons using:

    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"dd/MM/yyyy hh:mm:ss"];

But when I use dateFromString: method I’m getting a null value.

What I’m missing?

Thanks.

-EDIT-

    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"dd/MM/yyyy hh:mm:ss a"];

    NSLog(@"INFO -> Test Date: %@",[df dateFromString:testQuestions.endDate]);
    NSLog(@"INFO -> Test Date String: %@",testQuestions.endDate);

    if ([[df dateFromString:testQuestions.endDate] earlierDate:[NSDate date]])
    {
        currentTestIsBeingSolved = NO;
    }

Log:

2012-04-09 22:15:29.073 Otsuka On[27184:707] INFO -> Test Date: (null)
2012-04-09 22:15:31.816 Otsuka On[27184:707] INFO -> Test Date String: 29/02/2012 12:00:00 AM

EDIT–

As @trudyscousin suggested I’ve started a new project and added this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"dd/MM/yyyy hh:mm:ss a"];

    NSLog(@"INFO -> Test Date: %@",[df dateFromString:@"29/02/2012 12:00:00 AM"]);
...

Now I’m not getting null but the date is not the same:

2012-04-09 22:26:19.189 TestDate[54705:207] INFO -> Test Date: 2012-02-28 23:00:00 +0000

What is going on with the dates?

Any config in Xcode?

Thanks.

  • 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-01T14:33:19+00:00Added an answer on June 1, 2026 at 2:33 pm

    The fact that you’ve suffixed your date and time with “AM” is what is doing it. You have to provide for that as well:

    @"dd/MM/yyyy hh:mm:ss a"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have struggling with to convert nsstring to nsdate format. I have a date
I am trying to convert an string date to a NSDate to make some
I have this code where I'm trying to get the current date and format
I have a NSString that is a date and time in this code: YYYY-MM-DD
I have date 2012-04-02 10:01:00 am I want to show this date in with
I have date in sting object in following format. dd/mm/yyyy I want to change
I have a Date format: 2009-08-10T16:03:03Z that I want to convert to: @MMM dd,
I have this date and time format: 2010-05-19 07:53:30 and would like to change
How to compare date in objective c. i have three date in nsstring format.
I have allocated a date formatter, and I am trying to format a 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.