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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:15:10+00:00 2026-06-05T10:15:10+00:00

I have a date like this : Mon, 04 Jun 2012 14:13:00 GMT and

  • 0

I have a date like this : Mon, 04 Jun 2012 14:13:00 GMT
and want to delete the time displayed so that I can have something like this : Mon, 04 Jun 2012

I tried the code below :

NSString *dateTex = [[stories objectAtIndex: storyIndex] objectForKey: @"date"];
NSLog(@"the object value is:%@",dateTex);    

//changing dates format
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"];    
NSDate *date = [dateFormatter dateFromString:dateTex];
[dateFormatter release];

NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
[dateFormatter2 setDateFormat:@"EEE, dd MMM yyyy"];
NSString *dateText = [dateFormatter2 stringFromDate:date];
[dateFormatter2 release];
NSLog(@"the object value is:%@",dateText);

The date is parsed from an xml file and saved in the NSString dateTex. Then I am trying to change the format and save the new date on NSString dateText. However when I try to print the dateText variable, I get the object value is (null).
Any ideas?

  • 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-05T10:15:12+00:00Added an answer on June 5, 2026 at 10:15 am

    You can try below code :

    NSString *dateTex = [[stories objectAtIndex: storyIndex] objectForKey: @"date"];
    NSLog(@"the object value is:%@",dateTex);    
    
     //changing dates format
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
    [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"]; 
    NSDate *date = [dateFormatter dateFromString:dateTex];
    [dateFormatter release];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateStyle:NSDateFormatterShortStyle];
    [dateFormatter setDateFormat:@"EEE, dd MMM yyyy"];
    
    NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
    [dateFormatter setLocale:enUSPOSIXLocale];
    
    NSString *my_date_string = [dateFormatter stringFromDate:date];
    //my_date_string returns like value Tue 05 jun 2012
    

    Welcome!

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

Sidebar

Related Questions

i have a long string of date . looks like that : Mon Jun
I have a sample data like this ID DATE TIME STATUS --------------------------------------------- A 01-01-2000
I have a date string that looks like the following javascript format. I want
I have a NSString like Mon Feb 06 20:02:17 +0000 2012 . I want
I have strings that look like these: {server}_{date:YYYYMMDD}{int:######} {server}_{date:MON DAY YYYY}{int:######} ...plus more, in
I have a value like the following Mon Jun 18 00:00:00 IST 2012 and
I have a date like this:- 20091023 i have to convert it to a
I currently have a date which is formatted in PHP like this date('D d
I have a data frame like this Date Team Score 1/1/2010 A 10 1/1/2010
I have a table like this: date day weather 2000-01-01 Monday Sunny 2000-01-02 Tuesday

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.