nsdate

How do I know when to release an NSDate object?

Do either or both of these date pointers requires a [release] when I'm done with them. How would i know this? I'm unsure since I'm not doing init explicitly. NSDate *date = [NSDate date]; NSDate *date = [dateWithTimeIntervalSince1970:100000000]; ...

How to compare two date?

I have three dates: (1) previousDate (2) currentDate (3) nextDate, I want to check whether currentDate is later then previous date and earlier than nextDate. How do I do that? ...

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

How to increment an NSDate...

I'm trying to implement a method that will increment an NSDate instance variable by one month. I'm having memory management problems with this. (I'm using MallocScribble and NSZombieEnabled, and getting the message: -[CFDate copy]: message sent to deallocated instance 0x3d9dfa0) My question comes down to: what's the best way to incremen...

iphone sdk:how to convert arabic date format to english?

Hello, I am working on an application in which i save Current Date in database but when my app runs in Arabic language the current date format is changed into Arabic.I mean the date format should be like this 09/02/2010 but the digits are converted to Arabic digits.So how do i convert them back to english digits even if my app running in...

Comparing an NSDate to [NSDate date]

I am trying to force a user to select a date in the future with a date picker. I obviously used the compare: method, however, when I do the following code, even if it's the same date as [NSDate date], it tells the executes the if statement. Here is my code: if ([datePicker.date compare:[NSDate date]] == NSOrderedAscending) // If the...

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

component year in objective-c always returns me 0001 (SOLVED)

hi. i need to get the actual year, only the year but when i search for the result, i get always 0001. why is it? with the component i can get the day and the month. ...

NSDate basic usage error

Next to a label showing the value of a slider i want to show the date that corresponds to a start date + the number of days in slider value units. When i move the slider the app crashes in the Simulator. As far as i could find out that happens when i try to create a new NSDate field and my startDate object being "out of scope". Reading...

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

NSDate for "beginning of next hour"

I'd like to make a countdown to the next full hour. It's pretty easy to countdown to a specific time, like: NSDate *midnight = [NSDate dateWithNaturalLanguageString:@"midnight tomorrow"]; how do I define an NSDate for "the beginning of every hour"? Thanks! EDIT: This is what I have currently. Having trouble integrating the solution...

convert string to nsdate

hi, it is possible to convert in iphone sdk (obj-c) a string to nsdate. thank you ...

iPhone: Converting Oracle Timestamp to NSDate or to Unix Timestamp (e.g. double)

Is there a good+easy way to convert an Oracle Timestamp to an NSDate object on the iPhone? I have asked my customer to give me a DB with timestamps as Unix Timestamp (doubles with 0 = start of 1970) but it seems to be a problem for them. Thanks. Note: You can easily convert a Unix Timestamp to an NSDate with [NSDate dateWithTimeInter...

How to add a time interval to an NSDate

I have an NSDate and a duration. I need to get the time after the duration... Given: NSDate is 2010-02-24 12:30:00 -1000 duration is 3600 secs I need to get 2010-02-24 13:30:00 -1000 Actually I am looking for the time, but I think I know how to do that if I can get the NSDate object reflecting the new time. I thought dateWithTime...

How to determine if an NSDate is today?

How to check if an NSDate belongs to today? I used to check it using first 10 characters from [aDate description]. [[aDate description] substringToIndex:10] returns string like "YYYY-MM-DD" so I compared the string with the string returned by [[[NSDate date] description] substringToIndex:10]. Is there more fast and/or neat way to check...

iPhone: How to Sort Dates Using NSDate ?

I have to sort objects based on NSDates. What are the options for sorting by NSDate? ...

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

Crash when converting string to date

In my app I DO NOT want to use the local time on the phone. I want to get the current time in GMT. To do this I have a date formatter with time zone set to GMT. I then do the following to get back the current time: NSString *dateOne = [df stringFromDate:[NSDate date]]; NSDate *date1 = [df dateFromString:dateOne]; My app gets an EXC_BA...

NSDateFormater from NSMutableArray value

Hi, I store some dates in my NSMutableArray, I want to retrieve them and change the format. For the moment I do this: NSDate *myDate = [self.dates objectAtIndex:0]; NSLog(@"myDate:%@", myDate); // 2010-03-02 NSDateFormatter *formatDate = [[NSDateFormatter alloc] init]; [formatDate setDateFormat:@"MMMM d YYYY"]; NSString *newDate = [f...

Convert from NSString to NSDate (even if you don't know the NSString format)

I have an NSString that might contain 5-10 different style dates and times. I need to convert all of them into NSDates. Does dateWithNaturalLanguageString no longer exist in iPhone SDK 3.1.3? I do NOT need to convert things like @"last Wednesday at 1 pm". I need to convert things like: @"01-Feb-2010" @"Feb 1, 2010" @"February 1, 2010"...