获取当前时间的前一周时间

来源:互联网 发布:网络摄像头客户端软件 编辑:程序博客网 时间:2024/04/29 14:22

for (int i=0; i<7; i++) {

      NSDate *nowDate = [NSDatedate];

      NSDateFormatter *dateFormatter = [[NSDateFormatteralloc]init];


     if (i == 6)

      {

        [dateFormattersetDateFormat:@"MMdd"];

      }else

      {

        [dateFormattersetDateFormat:@"dd"];

      }


     NSDate *timeDate = [NSDatedateWithTimeInterval:-(i+1)*24*60*60sinceDate:nowDate];//前一天

     NSString *timeString = [dateFormatterstringFromDate:timeDate];

     NSLog(@"lastDay:%@",timeString);

}



1 0
原创粉丝点击