UIDatePicker / NSDateFormatter 时差,时制

    if ( self.remaindDatePicker==nil) {
        self.remaindDatePicker = [[UIDatePicker alloc] init];
    }
    self.remaindDatePicker.frame = CGRectMake(0, CGRectGetMaxY(self.buttonStart.frame)-30+20, kAlertWidth, kAlertHeight-[MyMethod getImageHeight:@"DxAlertViewClose.png"]-CGRectGetMaxY(self.buttonStart.frame));
//    datePicker.datePickerMode = UIDatePickerModeCountDownTimer;
    
    
    ////与本地显示 12时制 24时制
      [self.remaindDatePicker setLocale:[NSLocale currentLocale]];
    self.remaindDatePicker.datePickerMode = UIDatePickerModeDateAndTime;
    self.remaindDatePicker.minimumDate=[NSDate date];
//    [datePicker setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
    
    
     ////  8个时差
    self.remaindDatePicker.timeZone=[NSTimeZone localTimeZone];
    
    [self.remaindDatePicker addTarget:self action:@selector(selectedDate7:) forControlEvents:UIControlEventValueChanged];
    self.remaindDatePicker.backgroundColor = [UIColor clearColor];
    [self addSubview:self.remaindDatePicker];




-(void)selectedDate7:(UIDatePicker *)picker{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
    [formatter setTimeZone:[NSTimeZone localTimeZone]];
    
    
//    NSLog(@"...123... = %@",[formatter stringFromDate:picker.date]);
    
    [self.currentDateString setString:[formatter stringFromDate:picker.date]];
    
}


阅读更多
个人分类: IOS swift
上一篇IOS/Swift 添加第三方字体
下一篇IOS 返回事件 UIBarButtonItem (二) 自定义backBarButtonItem
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭