nsdate

How Do I write a Timer in Objective-C?

I am trying to make a stop watch with NSTimer. I gave the following code: nst_Timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(showTime) userInfo:nil repeats:NO]; and it is not working in milliseconds. It takes more than 1 millisecond. ...

[iPhone dev] NSPredicate with NSDate and repeats (like Calendar app)

Hi, I have an entity "Event" witch contains two properties: date (NSDate) and repeat (NSInteger - 0 = NONE, 1 = DAILY, 2 = WEEKLY, 3 = MONTHLY, ...). Does anyone knows how can I filter events by repeats passing a date ? Example: First event: 01-01-2010 / weekly Second event: 10-02-2010 / monthly Current date: 10-06-2010 Re...

Objective C - How can i get the weekday from NSDate ???

I need to be able to get the weekday from nsdate, i have the following code and it always return 1. I tried to change the month, i tried everything from 1 to 12 but the result of the week day is always 1. NSDate *date2 = [[NSDate alloc] initWithString:[NSString stringWithFormat:@"%d-%d-%d", 2010, 6, 1]]; unsigned units2 = NSYearCalendar...

NSString long date format to NSDate

I have a string in the form of "11:00AM, Saturday August 21, 2010" How do I convert this to an NSDate object? ...

Use of NSDate to get dates

I have attempted this is many ways but failed consistently, hopefully you guys can help me achieve the what i want to do. I am making an iPad app, I will have five tables in a single view and each table will have a date as a header/title in this format, e.g. Monday 20 These five tables will be monday to friday. This is the bit I cant d...

NSDateFormatter encoding vs decoding is not consistent

When I use this date formatter, it's not giving me back the same date I start with if I got from date -> string -> date. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setFormatterBehavior:NSDateFormatterBehavior10_4]; [formatter setDateFormat:@"MMM d, YYYY hh:mm aaa"]; NSDate *date = [NSDate date]; NSString *s...

Getting wrong date with initWithTimeInterval: sinceDate:

Hi, I have a date, 2010-08-23 13:30:00 -0400 and I'm trying to get it in the UTC +2 time zone. The difference in seconds is 21600 but when I call [[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate];, I get 2010-08-24 01:30:00 +0200 which should be 2010-08-23 19:30:00 +0200. Any idea what I'm doing wrong? ...

NSDate/NSCalendar Issue

Hi, I have the following code in my app. Its an iPad app, with five tables in a single view named monTable, tueTable etc. These tables represent monday to friday. In this code I get the date and set each table title to the date monday to friday (this week). Then if I press a button nextWeek becomes TRUE and I reload table data. This the...

NSDateComponents setWeek - Find this week

Is it possible to find the current week of the year using NSDateComponents and setWeek: ? As setWeek uses a number form 1 - 52 every week in the year, how can I find the number representing this week? ...

Can I use NSDateFormatter to convert this date string to an NSDate?

I have this string... 2010-08-24T16:00:00-05:00 and I'd like to extract the time portion from it (i.e. 16:00) and convert it to its 12-hour equivalent (i.e. 04:00 pm). I'm trying to use NSDateFormatter to accomplish this, but it's not working... NSDateFormatter* dateformatter = [[NSDateFormatter alloc] init]; [dateformatter setDateF...

How to get the date from specific string format using tome zone in iphone

hello all I have the date in string format "2009-07-06T02:05:11.000+10:00" which i have taken from xml.. Now i need to convert that into date format and use it.How could I do this Thanks all ...

iPhone XCode creating an if statement relating to a date

Hey guys, So I am new to the development thing, making me yes a noob. I am currently creating my first iPhone app and in it I have a countdown relating to when a web video service is launching. Under the countdown I have a button that allows playing the video stream, I would like to create an if statement that tells the app to reference...

Sort Date[dd/MM/yyyy] which is in NSString data type inside an array in Objective-C for iPhone

Hello, I have an NSMutableArray which holds the dates in format dd/MM/yyyy of type NSString. Now i need to display the sorted array of dates. Please suggest me how to achieve it. Thank You. ...

How to clear NSDate milliseconds

I want to keep date/times in a CoreData store with no seconds or milliseconds. (I'm doing some processing to round times off, and stray seconds/milliseconds become a monkey wrench.) It's easy enough to drop the seconds: NSDate *now = [NSDate date]; NSDateComponents *time = [[NSCalendar currentCalendar] compon...

iPhone UIDatePicker setMaximumDate

Hi, I am trying to build a datepicker which has today as a minimum date and 1 Feb 2011 as Maximum date. I have set the minimum date as followed [picker setMinimumDate: [NSDate date]]; and this works just fine but the MaximumDate does not seem to be correct. [picker setMaximumDate: [NSDate dateWithNaturalLanguageString:@"11/02/01"]];...

How to convert NSString with day light saving to NsDate

I have an NSString like this @"2010-08-30T11:00:00-04:00" . How to convert this to an NSDate ? Which DateFormat should be used with it ? I tried this @"yyyy-MM-dd'T'HH:mm:ss-SSS" . But didn't worked. Please help me. Edit I found @"yyyy-MM-dd'T'HH:mm:ss-SSS" was working fine in OS version 3.1 . But its not getting in 4.0 .This questi...

Converting String to NSDate issue

Hello all, I have been looking over StackOverflow and have not found any answers yet, if I missed a post which answers this I apologize and would be grateful for the link. I am trying to change a string "prod.Start" into a NSDate type for comparison with today's date. The following code myDate returns "1753-01-01 00:00:00 -075258" CO...

Date format for 2008-02-01T10:03:23.793-06:00

Hi All, In my project i am getting "2008-02-01T10:03:23.793-06:00" this date format in string i have to convert into NSDate i am using NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; NSDate* dateFromString = [dateFormatter dateFromString:@"2008-02-01T10:03...

iPad Dev: Turn a given Date or String from SQL into NSDate

I have an app that creates and stores a session with a given start date. The user would create a new work session and when they start it, the current time would get saved to the database. The app needs to count time between the start and end of a work session. However, I need to be able to pause, restart, and continue sessions, so I n...

UIDatePicker: time mode: initialize the time (gotta be simple)

All, This seems like such a simple thing, but I cannot find* the right method to create a UIDatePicker, in time mode, and have it initialized to a specific time. I don't want date -- just time (think alarm clock). I have created a NSDate object: NSDate * date = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: (NSTimeInterval) ...