获取系统当前时间

来源:互联网 发布:大学生it就业培训 编辑:程序博客网 时间:2024/06/06 10:54
NSString *appKey(){//    // 获取系统当前时间//    NSDate * date = [NSDate date];//    NSTimeInterval sec = [date timeIntervalSinceNow];//    NSDate * currentDate = [[NSDate alloc] initWithTimeIntervalSinceNow:sec];//    //    //设置时间输出格式://    NSDateFormatter * df = [[NSDateFormatter alloc] init ];//    [df setDateFormat:@"yyyyMMddHHmmss"];//    NSString * na = [df stringFromDate:currentDate];        //取毫秒    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];        [dateFormatter setDateStyle:NSDateFormatterMediumStyle];        [dateFormatter setTimeStyle:NSDateFormatterShortStyle];        [dateFormatter setDateFormat:@"SSSSMMddHHmmss"];//毫秒-月-日-时-分秒        NSString *time = [dateFormatter stringFromDate:[NSDate date]];    NSString *appKey = [NSString stringWithFormat:@"%@%@",time,[[NSString stringWithFormat:@"ecej12345678%@",time] md5HexDigest]];        return appKey;}

1 0