I want to get the date / time an hour before a given date / time.
Let's say the given date / time is 2012-11-25 13:20:35 (YYYY-mm-dd hour:minute:second).
I want to get the date / time an hour before a given date / time.
Let's say the given date / time is 2012-11-25 13:20:35 (YYYY-mm-dd hour:minute:second).
You should read Date and Time Programming Guide in the Apple documentation.
Here's something to get you on your way:
NSTimeInterval secondsPerHour = 60 * 60;
NSDate *givenDate = ...; // what you have already
NSDate *earlierDate = [givenDate dateByAddingTimeInterval:-secondsPerHour];
Note the minus sign in front of secondsPerHour, since it's earlier.
you can use:
NSDate *minusOneHr = [[NSDate date] dateByAddingTimeInterval:-60*60];