Substracting 1 hour from a nstimeinterval value

1.2k views Asked by At

Can we substract (say 1 hour) from the given nstimeinterval eg: 1416528000.000000 ?

  NSDate *  today1 = [NSDate date];
  NSTimeInterval  today = [today1 timeIntervalSince1970];

Substracting 1 hour from today?

2

There are 2 answers

0
Cyrille On BEST ANSWER

A NSTimeInterval is measured in seconds. If you substract 3600 from it, you'll go back one hour in time (60 minutes * 60 seconds per minute).

0
AudioBubble On

You can add or subtract time (in seconds) to get a new time interval. You can also use this code to get time interval since 1970 - N hour,

[[[NSDate date] dateByAddingTimeInterval:-N * 60] timeIntervalSince1970];