其实在我simulater时间显示近5个小时30分钟问题显示5小时30分钟过去时
我目前在印度的时间是2013年4月2日09:10 :__ AM但产量是2013年4月2日3点54分51秒 +0000
2013-四月 - 2日:上午9:10
我需要得到两个日期之间1.首先一些成果当前日期至2.当前日期
即从4月1日至4月2日上午9.10 T0当前时间2013年4月2日09:10 :__ AM
但dispalys
日期一个月的第一天为2013- 03- 31 18:30:00 +0000
当前时间为2013- 04-02 03:54:51 +0000 ,但实际时间是09:10:上午__
我COM普特月份的第一次约会如下
// TO IMPLEMENT CODE for FIRST DAY OF the Month
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* comps = [calendar components:NSYearForWeekOfYearCalendarUnit |NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:[NSDate date]];
calendar.timeZone = [NSTimeZone systemTimeZone];
[comps setWeekday:1]; // 1: sunday
monthComponent = comps.month;
yearComponent = comps.year;
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy MM dd"];
dateFormatter.timeZone = [NSTimeZone systemTimeZone];
// To get the firstDateOfMonth for This MONTH.
NSDate *firstDateOfMonth = [dateFormatter dateFromString:[NSString stringWithFormat:@"%d %d 01",yearComponent,monthComponent]];
NSLog(@"firstDateOfMonth-- %@ \r\n",firstDateOfMonth);
NSLog(@"[NSDate date]-- %@",[NSDate date]);
我设置时区SystemTimeZone甚至认为i got wrong results for Current date and firstDateOfMonth
在此先感谢
不,这个问题是对NSDate的误解。 – gnasher729