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

  • Home
  • SEARCH
  • 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 9123005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:14:10+00:00 2026-06-17T06:14:10+00:00

Hi i’m trying to format my NSString . But its not working. I tried

  • 0

Hi i’m trying to format my NSString. But its not working. I tried all the answers which i got in stackoverflow, But nothing works for me.

NSLog(@"log 1: %@ %@", [dealDetailsDict objectForKey:@"DealDateViewed"], [[dealDetailsDict objectForKey:@"DealDateViewed"] class]);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"log 2: %@ %@", [df stringFromDate:[dealDetailsDict objectForKey:@"DealDateViewed"]], [df dateFromString:[dealDetailsDict objectForKey:@"DealDateViewed"]]);

I don’t know what is the problem is here, both stringFromDate and dateFromString returning nil. This is my NSLog.

log 1: 2013-01-09 10:02:45 +0000 __NSCFString
log 2: (null) (null)

I want to display date like 31-12-2010. So i set,

[df setDateFormat:@"dd-MM-yyyy"];

Here my problem started.

  • 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-17T06:14:11+00:00Added an answer on June 17, 2026 at 6:14 am

    Use below functionality for date format…

    -(NSString*) Dateformate:(NSString*)str
    {    
        NSDateFormatter *dfrt =[[NSDateFormatter alloc] init];
        [dfrt setDateFormat:@"yyyy-MM-dd h:mm:ss"];
        NSDate *presentdate = [dfrt dateFromString:str];
        [dfrt setDateFormat:@"MMMM"];
        NSString *fullMonth = [dfrt stringFromDate:presentdate];
    
        [dfrt setDateFormat:@"yyyy"];
        NSString *yearStr = [dfrt stringFromDate:presentdate];
       // NSLog(@"month %@",presentdate);
    
        [dfrt setFormatterBehavior:NSDateFormatterBehavior10_4];
        [dfrt setDateFormat:@"d"];
        int date_day = [[dfrt stringFromDate:presentdate] intValue];
        NSString *suffix_string = @"|st|nd|rd|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|th|st|nd|rd|th|th|th|th|th|th|th|st";
        NSArray *suffixes = [suffix_string componentsSeparatedByString: @"|"];
        NSString *suffix = [suffixes objectAtIndex:date_day];
    
        NSString *fullDateFormat = [NSString stringWithFormat:@"%@ %d%@ %@",fullMonth,date_day,suffix,yearStr];
    
       // NSLog(@"fullDateFormat %@",fullDateFormat);
    
        return fullDateFormat;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
I am trying to understand how to use SyndicationItem to display feed which is
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.