I would like to subtract 4 hours from a date. I read the date string into an NSDate object use the following code:
NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate * mydate = [dateFormatter dateFromString:[dict objectForKey:@"published"]];
W...
I am getting this warning in xcode 3.1.3 iphone os 3.0.
This method is also not available in the NSDate class.
But I am getting the date from this method.
Can anyone please tell me How can I get rid of this warning????
...
In C#, if I wanted to parse out a string into a date and timespan, I'd do something similar to the following:
String input = "08:00";
DateTime time;
if (!DateTime.TryParse(input, out time))
{
// invalid input
return;
}
TimeSpan timeSpan = new TimeSpan(time.Hour, time.Minute, time.Second);
My Google-Fu has been less than desir...
I've been trying to find a sensible way of storing daily data using Core Data on the iPhone.
My app receives data in csv format, with a date but no time:
date, cycles
2009-08-01, 123
2009-08-02, 234
2009-08-03, 345
2009-08-04, 456
When this data is stored, there should only be one record per day. I figured the best thing to do was cr...
I have an NSDate object created by
NSDate *date = [[NSDate alloc] init];
Later, I want to reset the date to the "now", so I thought that
[date init];
or
date = [date init];
might do the job, but they don't. Instead,
[date release];
date = [[NSDate alloc] init];
works. I'm a bit confused about this, since in the documentation ...
I have a Date format:
2009-08-10T16:03:03Z
that I want to convert to:
@"MMM dd, HH:mm a"
I retrieve the xml format in an NSString. I tried to use the NSDateformatter:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMM dd, HH:mm a"];
any ideas?
...
Writing an iPhone app in Objective-C, I have a date in string form (in UTC format, with a Z on the end to denote zero UTC offset, or zulu time), which I need to parse into an NSDate object.
A bit of code:
NSDateFormatter* df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
NSString* str = @"2009-08-11T06...
Does anyone know how to convert a NSDate to JSON Date(ticks) to have sent to a .net web service?
...
Does anyone know how to convert a UTC NSDate to local timezone NSDate in Objective C?
...
What setDateFormat option for NSDateFormatter do I use to get a month-day's ordinal suffix?
e.g. the snippet below currently produces:
3:11 PM Saturday August 15
What must I change to get:
3:11 PM Saturday August 15**th**
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[date...
Trying to select a date (x) days from today's date, where the date would be start of day (e.g. 12:00am that day).
For example, a query with date 5 days earlier..
@"select pkey, dateofmod from data WHERE dateofmod >= date('now', '? days')" , [NSNumber numberWithInt:-5];
doesn't seem to work. (using FMDB).
...
Hi Everyone:
I am wondering if there is some way that I can create a timer that countdown from a given time. For example, say I want this timer to last an hour. There will be a NSTextField that will show the time remaining (ex. 25 minutes), and will auto update every minute to the new value. And then, when an hour is finally passed, ...
I've got a Core Data model set up, with two entities in a one-to-many relationship (Items, and for each item, there can be multiple ResetDates). I'm pretty confident the model is set up correctly.
I can add new Items, and when doing so, add a new ResetDate (using the current date, with [NSDate date]). I can retrieve and display Items. W...
I'm creating a report generator in Cocoa, and I need to produce convenient date ranges such as "Today", "This Week", "This Month", "This Year", etc.
Is there a good way to do this? Here is my skeleton thus far:
@interface DateRange : NSObject
{
NSDate startDate;
NSDate endDate;
}
@property (assign) NSDate * startDate;
@propert...
In the iPhone docset for NSDate, in the discussion area they discuss -dateWithNaturalLanguageString:locale:, however they don't document the method elsewhere on the page.
I've used the method before for iPhone and it worked just fine, although I got warnings. Now that I'm building with -Werror (which I should have been doing all along ^...
Hi,
I store my NSDates to a file in the international format you get when you call description on a NSDate.
However, I don't know how to go back: from the string-format to a NSDate object. NSDateFormatter seems to be limited to a couple of formats not including the international one.
How should I go back from the string-format?
Thank...
There are some constants for NSLocale, like NSJapaneseCalendar, but what if I wanted to create a "Physical Calendar" or something that isn't there? Is there a way to define an arbitrary calendar system and then use that with NSDate, NSDateComponents and NSCalendar?
...
I got a string that contains the current date by using this :
NSString *date = [[NSDate date] description];
At a different point I am want to retrieve the date from this string and I use the following code
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
NSDateFormatter *dateFormatter = [[NSDateFormatter...
Hello all ,
I'd like to create some sort of timer that will take the time between firing different kind of functions but I'm having no such luck so far. I assumed I should use the NSDate object and I've done this so far.
I've created several functions
-(void)startTime:(id)sender
{
starttime = [NSDate date];
**[starttime re...
I have 2 arrays with time values in it. They are in the following format. mm:ss:hundreds of a sec. I want to get the difference between the two [lastObjects] in the arrays. NSDate is not working because the last value is in hundredsth of a sec.
A question. If the second date is larger than the first will it give me a negative numb...