nsdateformatter

Why can't I correctly parse this date string with NSDateFormatter?

I'm trying to parse a string that was generated by an NSDateFormatter using another NSDateFormatter with the same format. Rather than trying to make that previous sentence make sense, here's some code: NSDateFormatter *format = [[NSDateFormatter alloc] init]; [format setDateFormat:@"MMM dd, YYYY HH:mm"]; NSDate *now = [[NSDate alloc] ...

iphone shortdate with 4 digit year

I am sure I am just missing something. But I have googled this for days trying to find how to show a 4 digit year when displaying an NSDate with a style of NSDateFormatterShortStyle. Please let me know if you have a solution. Here is the code I am using now. [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4]; ...

Covert NSString to NSDate in a different timezone

Hi I am trying to convert a string to date in a separate time zone from the current system time zone. I have set the time zone of the dateformatter to this timezone. But the NSDate I get is always in my current time zone. For instance, my current time zone is PDT. I have set the DateFormatter's time zone to CST. I have a string with th...

NSDate and NSDateFormatter - short format date and time in iphone sdk

searched for answers, but the one's i found didn't seem to be ipone specific. I basically need to get current date and time separately, formatted as: 2009-04-26 11:06:54 edit: The code below, from another question on the same topic, generates now: |2009-06-01 23:18:23 +0100| dateString: |Jun 01, 2009 23:18| parsed: ...

Using NSDateFormatter on the iPhone, protect locale but lose date components.

Hi This is a slightly tricky question. I am using NSDateFormatter on the iPhone but I wanted to only show a standard date without the years component. But retain the users locale formatting for their date. I could easily override the formatting using [dateFormatter setDateFormat:@"h:mma EEEE MMMM d"]; // hurl.ws/43p9 (date formattin...

Instruments (Leaks) and NSDateFormatter

When I run my iPhone app with Instruments Leaks and parse a bunch of NSDates using NSDateFormatter my memory goes up about 1mb and stays even though these NSDates should be dealloc'd after the parsing (I just discard them if they aren't new). I thought the malloc (in my heaviest stack trace below) could become part of the NSDate but I a...

How to Convert XML Date format to Cocoa

I have a Date format: 2009-08-10T16:03:03Z that I want to convert to: @"MMM dd, HH:mm a" I retrieve the xml format in an NSString. I tried to use the NSDateformatter: NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"MMM dd, HH:mm a"]; any ideas? ...

Nil NSDate when trying to get date from UTC string in zulu time

Writing an iPhone app in Objective-C, I have a date in string form (in UTC format, with a Z on the end to denote zero UTC offset, or zulu time), which I need to parse into an NSDate object. A bit of code: NSDateFormatter* df = [[NSDateFormatter alloc]init]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; NSString* str = @"2009-08-11T06...

Ordinal Month-day Suffix Option for NSDateFormatter setDateFormat

What setDateFormat option for NSDateFormatter do I use to get a month-day's ordinal suffix? e.g. the snippet below currently produces: 3:11 PM Saturday August 15 What must I change to get: 3:11 PM Saturday August 15**th** NSDate *date = [NSDate date]; NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [date...

NSString to NSDate

I got a string that contains the current date by using this : NSString *date = [[NSDate date] description]; At a different point I am want to retrieve the date from this string and I use the following code [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4]; NSDateFormatter *dateFormatter = [[NSDateFormatter...

Two Digit Years with NSDateFormatter not working

I have a 10.4 style date formatter applied to an NSTextFieldCell. I call setTwoDigitStartDate: (tried with both the epoch date and the "reference" date) but when I type in a date with a two digit year it sets the year to 0009 instead of 2009. Header: IBOutlet NSTextFieldCell *transactionDateField; // outlet *IS* set correctly in IB I...

How do you interpret dates with NSDateFormatter?

In the Apple Docs, they say that NSDateFormatter uses the Unicode for spec. I've read the spec, but I'm having troubles interpreting this date: NSDateFormatter *frm = [[NSDateFormatter alloc] init]; [frm setDateFormat:@"EEE MMM dd HH:mm:ss ZZZ yyyy"]; NSLog(@"Tue Oct 13 09:24:15 +0000 2009 becomes %@", [frm dateFromString:@"Tue Oct 13 ...

NSDateFormatter dateFromString will not parse a particular date string

Good day, i have an NSDateFormatter that doesn't seem to like a particular string that i am trying to convert. this particular instance is 2009-10-16T09:42:24.999605 All of my other dates are formatted the same, and can be parsed. Here is the code that converts the string in the NSDate. NSDateFormatter *dateFormatter = [[NSDateFor...

Converting a date (string) into another date format (string)

I have a novice question, will be happy if any one out there can help me. I have an NSMutableArray, for example: { JobID = 109302930; Subject = "Test Subject"; SubmitDate = "2009-09-15 17:27:34"; } I am now trying to create sections in my table view and want to group my records based on "formatted" SubmitDate. For example; 16th May'...

NSDateFormatter returns 1970 instead of current year with format MM/dd

The following code: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"MM/dd"]; NSDate *newTime = [dateFormatter dateFromString:@"10/01"]; sets the resulting date to 10/01/1970. Is there a "right" way to have the formatter assume that you mean a date in the current year, or c...

Date Formatters in NSDateFormatter

Hi all, The documentation is not clear about the date formatters NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:MM"]; What are the availabe dateFormats ???? Thanks ...

NSDateFormatter gives different values on device and simulator? What is work around?

Hi, I am using NSDateFormatter, the problem is with its consistency. If I use the kCFDateFormatterMediumStyle it gives the format as "Nov 26, 2009" in simulator but on device it gives "26-Nov-2009". Now I have the question, Is this NSFormatter trustable means in near future or updates from apple can it change the style again? ...

iphone NSDate NSDateFormatter to a ceratin format

Hello Everybody, i want to convert my NSDate to a certain format which is: "Wednesday, December, 2, 2009" does anybody know what is the corresponding format string to that date example? appreciate your help! ...

NSDateFormatter: I Don't want the time!

I am playing around with the coredatabooks source code example from the apple website, or here. I am trying to set the books copyright date attribute value to replace the author as the tableview section header, and I need the date value to be static, meaning I don't need the time, otherwise all of the date values are different, and no tw...

Parsing a RFC 822 date with NSDateFormatter

I'm using a NSDateFormatter to parse a RFC 822 date on the iPhone. However, there is no way to specify optional elements in the date format. There are a couple of optional parts in the RFC 822 specification which is breaking the date parser. If nothing works out, I'd probably have to write a custom parser to obey the specs. For example,...