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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:28:48+00:00 2026-06-06T19:28:48+00:00

I’m working with some NSDate objects, and well, I use my iPhone with 24

  • 0

I’m working with some NSDate objects, and well, I use my iPhone with 24 hrs format, so when I was testing my app, everything went fine, but, one of my friends tried the app on his iPhone, but he uses 12hrs format, after some research I found out that the problem was the date, and I have no idea why
I use this to set a date picker and a time picker, so I read some values from a database (yes, I’ve checked the values and they are correct, it is not a value-issue), so all this data is formatted and put together as a NSDate, then, I set the date picker and time picker with this date I just created

NSDateFormatter *currentDate = [[[NSDateFormatter alloc] init] autorelease];
[currentDate setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate * startDate =[currentDate dateFromString:[NSString stringWithFormat:@"%d-%d-%d %d:%d",yearVal,monthVal,dayVal,hourVal,minVal]];
[datePicker setDate:startDate];
[timePicker setDate:startDate];

So, yearVal, monthVal, dayVal, hourVal, minVal are all NSIntegers…
the thing is, that, it perfectly works if your iPhone/iPod is using 24 hours in your clock settings, but, if you are using 12 hours format, it crashes and shows this error message

> *** Assertion failure in -[UIDatePickerView _updateBitsForDate:forced:andReload:animateIfNeeded:], /SourceCache/UIKit/UIKit-1914.85/UIDatePicker.m:1200 2012-06-29
> 01:19:15.753 MyApp[1215:707] *** Terminating app due to uncaught
> exception 'NSInternalInconsistencyException', reason: 'Invalid
> parameter not satisfying: date'
> *** First throw call stack: (0x3710188f 0x34e06259 0x37101789 0x379403a3 0x31042807 0x30f616c5 0x30f61563 0x31042385 0xf48ef 0xf7bd3
> 0x30e0ec8b 0x30e1b1e9 0x30e1b059 0x30e1af3f 0x30e1a7c1 0x30e1a503
> 0x30e0eaff 0x30e0e7d5 0xdd945 0x30e8793d 0x30f01627 0x37972933
> 0x370d5a33 0x370d5699 0x370d426f 0x370574a5 0x3705736d 0x33816439
> 0x30e03cd5 0xd4cbb 0xd4c60) terminate called throwing an
> exception(gdb)

So please, if you have any idea of how to fix this, I would appreciate your help

oh, and I’ve read that HH returns hours in 24 hours format, well, all my app uses HH, so i don’t understand why I keep watching some “a.m.” or “p.m.” in some of the NSLogs i print to debug

Thanks in advance

oh sorry, I almost forget if i comment the lines

[datePicker setDate:startDate];
[timePicker setDate:startDate];

the app doesn’t crash, but of course, it doesn’t show the time and date I require

NOTE: I need to use 24 hours format, if I decide to select format with am pm I will have to change all my app, and well, I don’t have enough time for that

  • 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-06T19:28:49+00:00Added an answer on June 6, 2026 at 7:28 pm

    Take a look at this like: Find if user prefers 12 / 24 Hour Clock?… think the second answer might be the best for you. Then depending on if the user’s device uses a 12 hour clock or 24 hour clock you can set your [currentDate setDateFormat:….] accordingly.

    If you want a 12 hour clock then set currentDate as follows:

    [currentDate setDateFormat:@"yyyy-MM-dd h:mm:ss a"];
    

    If you want a 24 hour clock then set currentDate as follows:

    [currentDate setDateFormat:@"yyyy-MM-dd HH:mm"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

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
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am writing an app with both english and french support. The app requests

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.