nsdateformatter

iPhone SDK - NSDateFormatter day + month

Hi Everyone, I would like to display only the day and month of a date. Basically the NSDateFormatterLongStyle but without the year. The problem I'm facing is the localization. In the english version it has to show for example 'January 14' and in french '14 Janvier'. Is there an easy way to print such dates? Or do I have use ifelse sta...

How to use NSDateFormatter with NSPopUpButton

I have an NSPopUpButton's content bound to an Array Controller of "Meeting" entities and it's content value bound to the same array controller, but to the "date" model key path. Everything works fine. But I'd like to format the way the date is displayed with an NSDateFormatter and I can't get it to work. Any hints? Is it even possible? ...

Objective-C: Unicode Date Format

Hi guys, I am trying to work out how to have the UNICODE representation of Sun, 03 May 2009 19:58:58 -0700 as eee, dd MMM yyyy HH:mm:s ZZZZ or something. I cant seem to get this working precisely ...

NSDateFormatter wrong output with string from stringWithDate:

Why does NSDateFormatter misinterpretes his own created dateString? NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"YYYY-MM-DD'T'HH:mm:ss.SSSZZZZ"]; NSDate *now = [NSDate date]; NSLog(@"Now: %@, Date: %@", [dateFormatter dateFromString:[dateFormatter stringFromDate:now]], now); produce...

iPhone - NSDateFormatter

Hello! I have a String with a datetime format: "YYYY-MM-DD HH:MM:SS". I use this in my source code: NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setDateFormat:@"%e. %B %Y"]; NSString *test = [formatter stringFromDate:@"2010-01-10 13:55:15"]; I want to convert from "2010-01-10 13:55:15" to "10...

Doing comparison on NSDates in different timezones?

Hi I have an array of NSDates which I build from strings using [NSDate dateFromString] In the xml I parsed to get the string there was also a timezone string. As far as I can see in the manual NSDate does not in it self deal with timezones. Do I need to always store this timezone value somewhere and pair it with the belonging NSDate eac...

NSDate in full style but without year

I'm working with Objective C for iPhone and have a NSDate that I want to display in full style but without the year. Right now I'm using the code below but it also show the year, and I don't want that. As I want to show the date in the right region format I cannot just delete the year in the end as in some countries the year will not be ...

how to convert datatime format in nSString?

I have got value from the xml 2009-11-23T05:24:41.000Z.Now i want to display string like this Wed, Nov 4, 2009 8:00 PM - Wed, Nov 4, 2009 9:00 PM How it possible? ...

How do you calculate the day of the year for a specific date in Objective C

This is something I found myself spending hours to figure out and therefor wants to share with you. So the question was, How do i determine the day of the year for a specific date? e.g. January 15 is the 15'th day and December 31 is the 365'th day when it's not leap year. ...

NSDateFormatter with 24 hour times

Hi, I have a countdown timer which countsdown from the current date/time to a specific future date/time. It is working great except for one problem. I input the future date using NSDateFormatter and dateFromString. It doesn't seem to be able to accept any time (hour) over 12 though indicating it is not support 24 hour clock. Is there a w...

Right way to convert string into NSDate?(iphone)

Hey Guys, In my app I store the date as a string("MM/dd/YYYY" format). In the DB. later when I retrieve the string I have to compare two dates, how do I achieve this? If I had used the"YYYY/MM/dd" format I could have directly compared it as strings. Now I have to convert back into NSDate object using "nsdateformatter" and "dateFromStri...

rfc850 date format and NSDateFormatter

Im having a hard tim getting the NSDateFormatter to give me a correct date format. I need it to look like this: Mon, 04 Jan 2010 10:10:00 GMT But I am getting: Mon, 04 Jan 2010 10:10:00 GMT+00:00 Using the format string: EEE',' dd' 'MMM' 'yyyy HH':'mm':'ss z No matter what value for timezone I use, the +00:00 appears to be stuc...

NSDateFormatter dateFromString and iPhone in 24 Hour Format Confusion

I'm having a problem. I get incoming time strings in 12-hour format, and I'm turning them into NSDate objects. When the iPhone is in 12 hour format, no problem. But when it's in 24 Hour format, things go wrong. Here's some sample code to demonstrate: NSString *theTime = @"3:19 PM"; NSDateFormatter *formatter = [[NSDateFormatter alloc] i...

Is there a simple way of converting an ISO8601 timestamp to a formatted NSDate?

If I use the following code: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm"]; NSDate *myDate = [dateFormatter dateFromString:@"2010-01-28T15:22:23.863"]; NSLog(@"%@", [dateFormatter stringFromDate:myDate]); It is successfully converted to a Date object, however, I...

Why is a documented NSDateFormatter init method not getting recognized?

I'm getting this warning (below) when trying to use NSDateFormatter. I am importing in my .h file so what is the prob? (Oh, and the same method generates an error (unrecognized selector sent...)) Here is the WARNING: warning: no '-initWithDateFormat:allowNaturalLanguage:' method found Here is the Code: NSDateFormatter *myFormatter ...

Why my NSDate Formatter can't convert correctly and returns null on device?

I have an NSDate Formatter that should create an NSDate from string and should return it formated. The problem is that the result of converting from String to NSDate is wrong, the bigger problem is that on iPhone OS 3.1.2 it returns null while in the simulator it returns a wrong date. //start formating date NSMutableString *rawNewsDate ...

Convert NSString to Chunks of NSString that has a date format

This might be simple. I have searched, not found yet. How do I convert the NSString @"20100216190205" to an NSString of format @"yyyy-MM-dd HH:mm:ss". ie: @"2010-02-16 19:02:05" EDIT: I wanted to avoid using the NSDateFormatter to be more generic, for other situations. ...

NSDate initializer problem on the iPhone

I am trying to do some basic operations with Dates on the iPhone. I want to take a string like "2010-02-19" and turn it into a string like "Friday, Feb 19." The strings I will be receiving will always be in 2010-02-19. Right now, I am running the following code that works, but it produces a warning that says "NSDate may not respond to...

Unicode Locale Data Markup for (e.g.) "Tue, 23 Feb 2010 06:00:44 PST"

Hi. I was parsing a XML feed and trying to convert it to a NSObject when I noticed that (e.g.) [NSDate dateFromString:@"Tue, 23 Feb 2010 06:00:44 PST"] returned nil. Then I tried to convert my string to a NSDate by using the NSDateFormatter. NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"EEE, dd MMM YYYY HH:m...

NSDate from NSString

I've read the DateFormatting guide and I'm still not able to get a working formatter. NSString *string = @"0901Z 12/17/09"; //This is a sample date. The Z stands for GMT timezone //The 0901 is 09h 01m on a 24 hour clock not 12. //As long as I can get the hours/min & date from the string I can deal with the time zone later NSDateForma...