nsdate

"hour" int taken from NSDate not behaving as expected at midnight??

I feel like I've lost my mind. Can someone tell me what's going on here? Also, I'm sure there is a better way to do what I'm trying to do, but I'm not interested in that now. I'd just like to solve the mystery of why my ints are not responding to logic as expected. // Set "At: " field close to current time NSDateFormatter *dateFormatter...

objective-c setting NSDate to current UTC

is there an easy way to init an NSDate with the current UTC date/time? ...

iPhone SDK NSString To NSDate

I got a string from parsing a XML file which looks like this: Fri, 09 Apr 2010 00:00:45 +0200 and the corresponding pattern should be this "EEE, dd MMM yyyy HH:mm:ss ZZ", but I get (null). This is my code: NSString *dateString = @"Fri, 09 Apr 2010 00:00:45 +0200"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateF...

core-data NSDate searching for unique days and sorting

Lots of information on NSDates about the place, but I haven't found a clear solution to this. I have a list of Event entities, each with potentially many EventSessionTimes. Event <--->> EventSessionTime In 1 table view I want to display a unique list of days that have Events, in another table view I want to show the events on a parti...

NULL value when using NSDateFormatter after setting NSDate property via XML parsing

Hello, I am using the following code to try and display in a time in a table cell. TimeSlot *timeSlot = [timeSlots objectAtIndex:indexPath.row]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@"HH:mm:ss"]; NSLog(@"Time: %@", timeSlot.time); NSDate *mydate = timeSlot.time; NSLog(@"Time: %@", myda...

How do I subclass NSDate?

Hi, I first time tried to subClassed an NSDate to give it 2 methods that I need. Compiles fine, but in runtime I try to access it I get an error. Lets say I just want the current date which is unmodified in the subClass: [myNSDate date]; I get the error -[NSDate initWithTimeIntervalSinceReferenceDate:]: method only defined for ab...

NSFetchedResultsController titleForHeaderInSection with formatted NSDate

In my Core Data app I am using a FetchedResultsController. Usually to set titles for headers in a UITableView you would implement the following method like so: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#>...

Underlying value of an NSDate (DateValue)

To debug a DB app I need to verify the datevalue against the value that arrives in my SQLiteDB. Is there a way to show the double(?)-value of an NSDate (in code covert it to a double?) ...

Core Data and NSDate

Hi ! I read this post but I don't really understand the code... I have a core data database with an Entity and some attributes. One of them is named "myDate" and has for type NSDate. Now I want to to display each date but eliminate dates with same day-month-year and display them ascendantly . Have you got an idea? Thanks a lot ! ...

Can't get NSDate to work correctly

Hello, having a strange issue, must be something I'm just not seeing. I set up a variable in the .h NSDate *checkIn; @property (nonatomic, retain) NSDate *checkIn; I'm setting a variable to todays date in the initWithNibName: checkIn = [NSDate date]; I also did synthesized it as well. Now later on in my program I use it to build ...

Objective-C NSDate memory issue (again)

I'm developing a graphing application and am attempting to change the renderer from OpenGL to Quartz2D to make text rendering easier. A retained NSDate object that was working fine before suddenly seems to be deallocating itself, causing a crash when an NSMutableString attempts to append it's decription (now 'nil'). Build & analyse doe...

How to create a specific date in the distant past, the BC era.

I’m trying to create a date in the BC era, but failing pretty hard. The following returns ‘4713’ as the year, instead of ‘-4712’: NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *components = [NSDateComponents new]; [components setYear: -4712]; NSDate *date = [calendar...

convert string to date and write back into NSMutableArray

I have a NSMutableArray I get by loading a plist into it. The date field comes in as a string and i want to change it into a nsdate. I can change an nsstring into an nsdate. My array is an array of objects like the one below; { Date = "1/1/2009" Description = "Have you ever looked at a badger and thought i wonder how far...

NSDate Convert milliseconds to NSDate.

Hi Guys I have this "1273636800000" I want this "Wed Mar 03 2010 00:00:00 GMT-0500 (EST)" I need to convert this milliseconds to NSDate format. I tried this NSDate *tr = [NSDate dateWithTimeIntervalSince1970:1273636800000]; and NSDate *tr = [NSDate dateWithTimeIntervalSinceReferenceDate:1273636800000]; and NSDate *tr = [NSDate ...

How to convert the date string into string( yyyy-MM-dd). While doing so, I getting null values ?

Hi, I have the data as customerFromDate " 01 Apr 2010 " and customerToDate " 30 Apr 2010 " which is a string. I want to convert that format into yyyy-MM-dd it should be in string. but while doing so. I got null values. Please see the following code which I had tried. printf("\n customerFromDate %s",[customerStatementObj.customerFromD...

iPhone: convert Nsstring to Nsdate on device timezone

hi all, I received date from Web service which is in GMT + 1 format (2010-02-25T20:16:50.387+05:30). I want to convert in NSdate. I have no proper idea about date formatter. Please suggest that how can i Change this nsstring value to current date format (Time zone) ...

Objective C: Compare timeInMillis with current time

Hello, In my iPhone application, I need to calculate the time difference between the time a message was created on the server, and the time my phone received it. The server (Java) puts in a number returned by System.currentTimeMillis() as metadata along with the message. How do I compare this number with the current time on the devic...

Parse ISO8601 date in Objective-C (iPhone OS SDK)

How do I parse "2010-04-30T00:45:48.711127" into an NSDate? (and maintain all precision) ...

Unable to Parse Date using NSDateFormatter

Hi, I am fetching a RSS, in which i receive the following Date stamp: 2010-05-10T06:11:14.000Z Now i am using NSDateFormatter to parse this datetime stamp. [parseFormatter setDateFormat:@"yyyy-MM-dTH:m:s.z"]; But its not working fine if just remove the time stamp part it works for the date [parseFormatter setDateFormat:@"yyyy-MM-d...

Adding two NSDate

Hi guys, I've got two NSDate, date and time. I'd like to add them in such a manner that I get the date from date and time from time. Any suggestions on how I do this? Cheers Nik ...