nsdateformatter

NULL value from NSDateFormatter from XML

Hi guys, This was working fine before compiling with iOS4.0 and I can't figure out what's wrong. Here's the problem. I send my app scores from my database with a date/time on it. My goal is to store that in CoreData. When I use the code below I get a null value for the date. Code: NSDateFormatter *dateFormatter = [[NSDateFormatt...

iPhone 4.0 NSDateFormatter crashes..

Hi all! I need to convert a NSDate to a string using my personal data format... The problem is that this code on the simulator (4.01) crashes... sometimes the code is "freezed", sometimes give the BAD_ACCESS... here is the code: NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; ...

iPhone Objective-C convert String to NSDate *special case

Hey everyone, I know this kind of questions have been asked a thousand times on this forum, but I have a slightly special case which I could really use some help with. I have an NSString *expirationDate with the value = "2010-06-23 04:28:59.341818" I need to convert to an NSDate object and compare against the current Date/Time. Can so...

NSDateFormatter problem

hey i have my date as "7/30/2010". How do i print it as only the Month and Date ie. "7/30" I tried using NSFormatter but it prints my current date and not which is present in my database. ...

Problem with negative date on iPad and not on simulator

I'm working on an history application so I need to cope with date before and after JC. I'm trying to parse a string with the form "01/01/-200" but it returns a null date while it's working with "01/01/200". Here is my code : NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc]init] autorelease]; [dateFormatter setDateFormat:@"dd...

Date Formatting in iphone

I am having a date as 2010-08-02 which is 2nd August 2010 now i want to dispaly this as Monday,8 August ,2010 Thanks for the help ...

A problem when converting string to date in iPhone?

How to convert NSString 2010-08-03 04:37:31.0 to August 3, 2010? Is it possible? ...

NSDateFormatter NSString w/ day suffix to NSDdate

I'm trying to use only a NSDateFormatter to format string representation of a date/time to an NSDate object. The issue is that I can't figure out how to allow the ordinal suffixes in the format. So lets say I have a string "Wednesday, August 11th 2010 8:00 PM" What one line NSDate dateFormat should I use? Like "EEEE, MMM dd'th' yyyy ...

NSDateFormatter parsing date incorrectly

I'm extracting strings from a text that represent dates. They look like this: Monday August 16, 2010 05:28 AM EST I'm trying to parse them with a NSDateFormatter. I've set its format to: [dateFormatter setDateFormat:@"EEEE MMMM d, YYYY h:mm a z"]; However, this doesn't work. For the example I gave above, if I convert the string to a ...

NSDateFormatter encoding vs decoding is not consistent

When I use this date formatter, it's not giving me back the same date I start with if I got from date -> string -> date. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setFormatterBehavior:NSDateFormatterBehavior10_4]; [formatter setDateFormat:@"MMM d, YYYY hh:mm aaa"]; NSDate *date = [NSDate date]; NSString *s...

Can I use NSDateFormatter to convert this date string to an NSDate?

I have this string... 2010-08-24T16:00:00-05:00 and I'd like to extract the time portion from it (i.e. 16:00) and convert it to its 12-hour equivalent (i.e. 04:00 pm). I'm trying to use NSDateFormatter to accomplish this, but it's not working... NSDateFormatter* dateformatter = [[NSDateFormatter alloc] init]; [dateformatter setDateF...

iPhone UIDatePicker setMaximumDate

Hi, I am trying to build a datepicker which has today as a minimum date and 1 Feb 2011 as Maximum date. I have set the minimum date as followed [picker setMinimumDate: [NSDate date]]; and this works just fine but the MaximumDate does not seem to be correct. [picker setMaximumDate: [NSDate dateWithNaturalLanguageString:@"11/02/01"]];...

How to convert NSString with day light saving to NsDate

I have an NSString like this @"2010-08-30T11:00:00-04:00" . How to convert this to an NSDate ? Which DateFormat should be used with it ? I tried this @"yyyy-MM-dd'T'HH:mm:ss-SSS" . But didn't worked. Please help me. Edit I found @"yyyy-MM-dd'T'HH:mm:ss-SSS" was working fine in OS version 3.1 . But its not getting in 4.0 .This questi...

NSDateFormatter problem with weekday EEE

Hello, Why does the following code output: Dday: (null) NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE HH:mm:ss"]; NSDate *date = [dateFormatter dateFromString:@"Sun 15:00:00"]; DLog(@"Ddate: %@", date); If I use the format HH:mm:ss and string 15:00:00 i get a valid date... Cheers...

dateFormat for timezone MDT in NSDateFormatter

Hi, I am developing an iPad application in which I need to convert a string in the format "Wed, 13 May 2009 05:36:20 MDT" to NSDate. I am using the following code: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss zzz"]; NSDate *pubDate = [dateFormatter dateFromS...

Converting String to NSDate issue

Hello all, I have been looking over StackOverflow and have not found any answers yet, if I missed a post which answers this I apologize and would be grateful for the link. I am trying to change a string "prod.Start" into a NSDate type for comparison with today's date. The following code myDate returns "1753-01-01 00:00:00 -075258" CO...

Date format for 2008-02-01T10:03:23.793-06:00

Hi All, In my project i am getting "2008-02-01T10:03:23.793-06:00" this date format in string i have to convert into NSDate i am using NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; NSDate* dateFromString = [dateFormatter dateFromString:@"2008-02-01T10:03...

Using NSDateFormatter to convert NSString to unix time -- Code works 50% of the time

This is really strange, I'm not sure what could be causing the code to work perfectly half of the time and not the other half. I'm using TBXML to parse a twitter feed. I need to get the created_at date in the twitter feed which is passed like <created_at>Tue Feb 02 23:30:49 +0000 2010</created_at>. So i store these values and then pas...

CoreData - How to set date and time independent of each other?

I have a coredata attribute called visitDate I want to set the date and time independently of each other using separate pickers. I realize that when I set the time, I need to grab the existing date, month and year of visitDate, but only set the time from the NSDatePicker. Conversely, when I set the date, I need to grab the existing ...

How can I convert a double into HH:MM:SS in ObjectiveC

I've got a double 0.27392 and I know it is 6:34:27 AM. This is simple in Excel, but I can't get NSDateFormatter to work its magic. ...