nsdate

Must I retain the date from a UIDatePicker Modal View?

I'm getting crashes from my UIDatePicker view and I think it's because I'm not retaining the pickers selected date. Can anyone tell me if this could be correct? I have a modal view for selecting a toDate and a fromDate range. These values are passed into the modal view and grabbed out of the view when it's dismissed. The view has one UI...

Number of days in given year using iPhone SDK?

I'm trying to get the number of days in a current year. When I try the solution on http://stackoverflow.com/questions/1179945/number-of-days-in-the-current-month-using-iphone-sdk, and replace NSMonthCalendarUnit by NSYearCalendarUnit, I still get the number of days for that month. Does anyone know how I should do this? Thanks in advan...

How can I get the date but not time from NSDate

Hi. I need the date as a string but not the time and it has to be localized. So for example USA should be Sep 25 2009 but for New Zealand it would be 25 Sep 2009. I can get the date into a string by specifying the format "MMM dd YYYY" but It's not localized. Any ideas? ...

Determine the number of months between two dates using Cocoa

Hello, How do I calculate the number of months between two dates using Cocoa? Thanks, Stan ...

GMT time on iPhone

How do I get GMT time? NSDate *c =[NSDate date]; gives system time, not GMT. ...

iPhone - How to return year as an integer from a given date?

Hi all, I'm trying to return the 4 digit year from any given date as an integer. I'm not strong with the NSCalendar or NSDate functions, but have tried using them with components from date and date formatters with no success. Thanks. ...

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

Sort NSArray by NSDate, today

Hi, I have loaded item from core data in an NSMutableArray. Each item, when created, is given a due date, that the user choices. How do I sort, so only the item that is due today is displayed? Here is what I got so far: NSPredicate *predicate = [NSPredicate predicateWithFormat: @"dueDate == %@", [NSDate date]]; [allObjectsArray ...

Getting first and last days of current week

How can I get first and last days of the current week? What I need is some way of filtering a set of objects with NSDate property to leave only ones, that appear on current week, and then filter them by days. Also I need some way to get localized day names. I've tried to play with NSCalendar, NSDate and NSDateComponents, but it seems th...

Whither NSDate dateByAddingTimeInterval on iPhone OS?

Greetings! I must be seeing things. Look at this excerpt from the iPhone OS reference library: addTimeInterval: Returns a new NSDate object that is set to a given number of seconds relative to the receiver. (Deprecated. This method has been replaced by dateByAddingTimeInterval:.) However, it is nowhere to be found in the docs...

how to save and retrieve date+time into sqlite3 database?

i want to save current date+time into database and also want to retrieve it. i know that in objective-C we cannot save date+time directly. i have double as a field into database and currently I'm saving date by converting it into double. here is the method for converting date into double- currentDate=[NSDate date]; startDate=(double)...

how to add hours in a nsdate?

i have a date converted to double value and saved in database.now i want to compare if cureentdate > myDataBaseDate+8 hours. means i want to get 8 hours more added in my database date. i'm converting date into double values.so how do i get 8 hours later time from my database saved date. how do i compare if(currentDateTime>DateFromdatabas...

How to convert every time zone in GMT +5.30?

I am creating an application. I am running a countdown timer and saving time into a database by converting time into a floating point value (double). Suppose I start the timer at 2.00 PM and set the countdown for 3 hours. After 1 hour I quit the application and on relaunch I am getting time stored from database. Count the difference betw...

how to compare dates in iphone sdk?

i have two dates i want to compare which one is greater date how do i do this in objective-c? ...

Get all days of any month with objective-c

A seemingly simple question...how can I return a list of days for any specified month? NSDate *today = [NSDate date]; //Get a date object for today's date NSCalendar *c = [NSCalendar currentCalendar]; NSRange days = [c rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:today]; I basically want to use tha...

[iPhone] Formatting an NSDate

Hi, I am pulling data from an RSS Feed. One of the keys in the feed is is a string representing the date and time the item was created. I am trying to convert this string value to an NSDate. The string value is returned from the RSS feed as: 2009-11-18T22:08:00+00:00 I tried the following code to no avail: NSDateFormatter *df = [[...

[objective-C] get time between two times of the day

Hey, I've already tried with NSDate but with no luck. I want the difference between for example 14:10 and 18:30. Hours and minutes. I Hope you can help me shouldn't be that complicated :) ...

Number of weeks in month

I have the following code: NSDate *dateNow = [[NSDate alloc] init]; NSTimeInterval timeDifference = [usersDate timeIntervalSinceDate:dateNow]; // Get the system calendar NSCalendar *sysCalendar = [NSCalendar currentCalendar]; // Create the NSDates NSDate *date1 = [[NSDate alloc] init]; NSDate *date2 = [[NSDate alloc] initWithTimeInterv...

Local Time To GMT conversion

hi everyone, can anyone suggest me a way to convert local nsdate object to Gmt in objective c. i have searched for the api but didnt get. thanks ...