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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:33:12+00:00 2026-06-16T17:33:12+00:00

i have and function that convert string to date. and its working very fine

  • 0

i have and function that convert string to date. and its working very fine but when i try to convert 20130331 the application crashs.
and here my code

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMdd"];
NSDate *date = [dateFormat dateFromString:dateStr];
NSLog(@"before %@ dateStr %@",date,dateStr);

the log is is following

2013-01-02 17:56:04.402 jana2ez[6067:11303] before 2013-03-28 22:00:00 +0000 dateStr 20130329 
2013-01-02 17:56:04.498 jana2ez[6067:11303] before 2013-03-29 22:00:00 +0000 dateStr 20130330 
2013-01-02 17:56:04.626 jana2ez[6067:11303] before (null) dateStr 20130331

any idea??

  • 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-16T17:33:13+00:00Added an answer on June 16, 2026 at 5:33 pm

    After hours of bad results, finally I found a solution inspired from @Echihl’s comment.

    I changed the time in the date so the date will be parsed to same date found in dateStr.

        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyyMMdd HHmm"];
        NSDate *date = [dateFormat dateFromString:dateStr];
        NSLog(@"before %@ dateStr %@",date,dateStr);
    

    My output becomes

        before 2013-03-31 05:00:00 +0000 dateStr 20130331 0800
    

    Previously 20130329 was parsed to March 28th, 2013, at 10 PM

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

Sidebar

Related Questions

I have a string in php that is a date but is formatted: mddyy
I have a function that takes a string date in the format 08/24/2010 and
I'm developing a function that extracts a date from a String and convert it
I have this function called ProperCase that takes a string, then converts the first
I have a function that convert ticks to time_t format long ticks = DateTime.Now.Ticks;
I have a function that converts 60000 into 60k or 60100 into 60.1k But
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I need a function to check a date with boolean. I have a String
I have this date format d-m-y on a string so that 01-01-12 is January,
As input, I have a date string that can take three general formats: 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.