nsdate

Comparing dates in Cocoa

hi i want to know how to get current date? i want to compare current date with a date i m fetching from a plist files using following code. NSDate *expDate = [licenseDictionary objectForKey:@"Expires"]; for comparison i m using the following code if([curDate compare:expDate] == NSOrderedAscending ) but its not working. can anybo...

Convert "current time" to "time in minutes since 00:00" calculation help..

I haven't used NSDate that much, so I'd like some help with a calculation I am doing. I have an integer that has my store's closing hour in minutes since midnight. Basically, my store closes at 5.00PM, which gives me the integer 1020. So right now it's 10.45PM or 22.45. Integer since 00:00 is 1365, and from this I can say if (storeHou...

Allow 0 values in NSDatePicker fields?

Is it possible to modify an NSDatePicker object to allow for 0 values in the month and/or day columns? Dealing with a situation where the specific day in particular is non-essiential but nice to have data (and data which the user likely doesn't know offhand to begin with). ...

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,...

Comparing two NSDates and ignoring the time component

What is the most efficient/recommended way of comparing two NSDates? I would like to be able to see if both dates are on the same day, irrespective of the time and have started writing some code that uses the timeIntervalSinceDate: method within the NSDate class and gets the integer of this value divided by the number of seconds in a da...

NSDate - Convert Date to GMT

Hello, I need the ability to convert a NSDate value to a GMT Date. How can I go about converting a NSDate value to a GMT formatted NSDate value, independent of what ever date locale settings the iphone is using. Kind Regards ...

get NSDate today, yesterday, this Week, last Week, this Month, last Month... variables

what i am trying to do is to get NSDate today, yesterday, this Week, last Week, this Month, last Month variables ready for comparison for headers to be added on UITableView's titleForHeaderInSection what i want is done manually in the code below for date 2009-12-11 NSDate *today = [NSDate dateWithString:@"2009-12-11 00:00:00 +0000"];...

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 ...

NSPredicate: filtering objects by day of NSDate property

I have a Core Data model with an NSDate property. I want to filter the database by day. I assume the solution will involve an NSPredicate, but I'm not sure how to put it all together. I know how to compare the day of two NSDates using NSDateComponents and NSCalendar, but how do I filter it with an NSPredicate? Perhaps I need to create ...

NSDate between two given NSDates

I am interested in creating a method to find if the current date falls between certain times on any given day. It is for a scheduling program, so I want to find what event is occurring at the current time. Every day has the same set of times: 820-900, 900-940, 940-1020, etc. Since this must be done on any given day I do not know how to c...

NSTimer not firing when runloop is blocked.

I am just about finished with my app and beta testing found a bug in the stopwatch portion... The stopwatch uses an nstimer to do the counting and has a table for storing laps, but when the lap table is scrolled the watch stops or pauses and does not make up for the lost time. This was stalling was eliminated by using: startingTime = [...

What's the optimum way of storing an NSDate in NSUserDefaults?

There's two ways of storing an NSDate in NSUserDefaults that I've come across. Option 1 - setObject:forKey: // Set NSDate *myDate = [NSDate date]; [[NSUserDefaults sharedUserDefaults] setObject:myDate forKey:@"myDateKey"]; // Get NSDate *myDate = (NSDate *)[[NSUserDefaults sharedUserDefaults] objectForKey:@"myDateKey"]; Option 2 - t...

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. ...

Tell what day it is using NSDate

Hi, I have an NSDate and I want to tell if it occurs on a particular day of any year. How do I do that? For instance, I want to see if NSDate's day and month are 25 and 12. I want to go: NSDate *today = [NSDate date]; int day = [today day]; int month = [today month]; Is there a way of doing that? ...

iphone: How do you find the creation date of a file?

hi all. I'm trying to find the creation date (NOT modification date) of a file. Creation date doesn't appear to be in the attributes of a file, though modified date is. I'm using this code.. NSFileManager* fm = [NSFileManager defaultManager]; NSString* path = [PathHelpers pathInDocumentsFolderWithFilename:FILE_NAME]; NSDictionary* a...

Create NSDate Monotouch

I am trying to take a date string and turn it into a specific NSDate (eg. July 1, 1981), but I don't see and methods for setting the date. Does anyone know how to accomplish this? Perhaps convert a DateTime object to NSDate? ...

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...