nsdate

Using NSDateFormatter to convert NSString to unix time -- Code works 50% of the time

This is really strange, I'm not sure what could be causing the code to work perfectly half of the time and not the other half. I'm using TBXML to parse a twitter feed. I need to get the created_at date in the twitter feed which is passed like <created_at>Tue Feb 02 23:30:49 +0000 2010</created_at>. So i store these values and then pas...

Why can't I control Core-Plot date-axis ticks?

I have a Core-Plot scatter plot that seems to be working great. The x axis shows date/time, the y axis a value from 0-500. I set up the x axis as follows: plotSpace.xRange = [CPPlotRange plotRangeWithLocation: CPDecimalFromFloat(maxTime - 2*60*60*24) length:CPDecimalFromFloat(2.5*6...

CoreData - How to set date and time independent of each other?

I have a coredata attribute called visitDate I want to set the date and time independently of each other using separate pickers. I realize that when I set the time, I need to grab the existing date, month and year of visitDate, but only set the time from the NSDatePicker. Conversely, when I set the date, I need to grab the existing ...

Setting an NSDate to specific date, time and timezone

I need to set a NSDate to a specific date, time and timezone for an iPhone App. The example code below works fine on iOS 4 as the setTimeZone was introduced with iOS 4. How could I easily set a NSDate to a date, time and timezone without using setTimeZone so it can be used on iOS 3.0 devices? NSDateComponents *comps = [[NSDateComp...

iphone NSDate - get todays date and force the time

hi guys - hopefully a quick one for someone! I am struggling to see why the code below isn't working. I am trying to get today's date (eg: 2010-09-10) and manually adding the time. It always seems to return 00:00:00 for the time though. any ideas where I'm going wrong? NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] au...

Using NSDateFormatter to format date to local date

I have tried numerous attemps of formatting a relatively simple date format to a date object, but also converting to my local time zone. All dates are formatte like this: 2010-09-11T08:55:00. This is GMT time, and I want it converted to a date object with GMT+2. Can anyone please point me in the right direction? ...

NSDate get year/month/day

How can I get the year/month/day of a NSDate object, given no other information? I realize that I could probably do this with something similar to this: NSCalendar *cal = [[NSCalendar alloc] init]; NSDateComponents *components = [cal components:0 fromDate:date]; int year = [components year]; int month = [components month]; int day = [co...

Long to nsdate in Objective C

I have an char array of 8 bytes which contains current date in long int. How can I convert this into NSDate. ...

create empty NSDate object

Is this ok? NSDate *myDate; Because I used something like this before: NSDate *myDate = [[NSDate alloc] init]; if (something) myDate = thisDate; else myDate = thatDate; [myFunction initWithDate:myDate]; I always got "Value stored to 'myDate' during its initialization is never read". If I do something like this if (some...

NSDate format in iOS 4.1

Hi All, [NSDate date]in iOS 4.0 used to return date in the format: 2010-09-15 09:28:26 +0530 but now in iOS 4.1 it returns the date in the format: 2010-09-15 09:28:26 GMT In my application it is leading to lots of problems. Does anyone know how to fix this? Thanks in advance, YPK ...

NSCalendar problem with BC era

Greetings, Recently I faced a big problem (as it seems to me) with NSCalendar class. In my task I need to work with a large time periods starting from 4000BC to 2000AD (Gregorian calendar). In some place I was forced to increment some NSDate by 100 year interval. When incrementing the years in AD timeline (0->...) everything worked fin...

NSDate for first day of the month

This is quite a simple concept, but as of yet I have been unable to find an elegant (and calendar locale independent) solution. I need to find the first day of the month for an arbitrary NSDate. For example, given an arbitrary NSDate (arbitraryDate) another NSDate object will be returned (let's call this firstDayOfMonthDate) which repres...

How to display NSTimeInterval binding as NSDate in InterfaceBuilder?

I handle a lot of time stamps that I store as NSTimeInterval. NSDateComponents* comps = [[NSDateComponents alloc] init]; [comps setYear: .... NSDate* date = [gregorian dateFromComponents:comps]; NSTimeInterval timeStamp = [date timeIntervalSinceReferenceDate]; Interface Builder has a table view binding to the variable of the time stam...

NSString to NSDate conversion problem

Hi all, I am having a NSString object which I am converting to NSDate with help of NSDateFormatter. Now code works fine here with all the OS but it is creating different Output at client's add (USA region). Here is the code that I am using. NSDateFormatter *formate = [[[NSDateFormatter alloc] init] autorelease]; [formate setDateFormat:...

I have an exact string as say "November 4, 2010" and I want to compare it with today's date in iPhone?

How can one convert a string "November 4, 2010" and not "MMMM d, YYYY" to NSDate for comparison? ...

Comparing to NSDates not working, incompatible pointer types

Hey i am trying to compare the date on which the user opens the app to the date it is currently. (basically, how long they've had the app in days) Here is the code: - (NSInteger) daysAfterDate: (NSDate *) aDate { NSTimeInterval ti = [self timeIntervalSinceDate:aDate]; //#1 return (NSInteger) (ti / D_DAY); //#2 } //#3 -(void)l...

NSDate formatting issues.

I am getting a headache from dealing with the data format, particulary the time offset components. I retrieve a DateTime field from sqlite3 and temporarily store it in a const char*. I convert this into an NSString*. I conver the NSString* to a NSDate. Now, before, I was using a date format something like this: "MM/dd/YYY hh:mm -0700...

Comparing time in NSDate

I am trying to compare the time from two NSDate objects but am getting the wrong answer. I think it is because when using the NSDate compare methods it is also including the date. I just want to ignore the date and compare the times. How can this be done? ...

NSDate* getting corrupted after a few render cycles. Why???

I have a general timer with a 1.5 second interval (the render cycle). I have a class with an NSDate* member/property (nonatomic, retain). I set this date by calling [callingClass setDate:expirationDate]; Now... a couple of render cycles this NSDate is valid. However, around the 3rd cycle the value of this variable gets corrupted, it s...

How do I create a Cocoa GUI to edit an array of NSDate objects?

In one app I am working on I need to let the user edit a list of dates. I have those NSDate objects in an array and bound that to a NSArrayController. I bound a NSTableColumn (the only column in a table view) to that array controller using the key path arrangedObjects.self. This works fine - I get all the dates displayed in the table jus...