i'm trying to have a NSTimeInterval of a NSDate with time set to zero, so the start of the day, but give me always my timezone that is GMT+2 and not GMT, i'm doing this:
This is the category to set the start of a day in a NSDate:
#define DATE_COMPONENTS (NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit | NSWeekdayOrdinalCalendarUnit)
#define CURRENT_CALENDAR [NSCalendar currentCalendar]
- (NSDate *) dateAtStartOfDay
{
NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:self];
components.hour = 0;
components.minute = 0;
components.second = 0;
return [CURRENT_CALENDAR dateFromComponents:components];
}
then i do this:
NSTimeInterval now = [[[NSDate date] dateAtStartOfDay] timeIntervalSince1970];
and give me this NSTimeInterval:
1375567200
that if i check on:
the gmt time is this:
GMT: Sat, 03 Aug 2013 22:00:00 GMT
Mine tiem zone: 04 agosto 2013 00:00:00 CEST GMT+2
how i can have always the GMT time interval? i'm looking for a solution that work at New York, Rome, Rio de janerio for example, have to give me the nstimeinterval to gmt where ever the user is, anyone can help me?