Showing App's Build Date

后端 未结 6 874
情书的邮戳
情书的邮戳 2021-02-04 05:23

I am able to display the build date for my app in the simulator, but whenever I archive the app, and upload it to TestFlight, and then install it on a device, the build date doe

6条回答
  •  抹茶落季
    2021-02-04 05:40

    To get build date with format 'yyMMddHHmm' you could try this:

    + (NSString *)GetBuildDate {
        NSString *buildDate;
    
        // Get build date and time, format to 'yyMMddHHmm'
        NSString *dateStr = [NSString stringWithFormat:@"%@ %@", [NSString stringWithUTF8String:__DATE__], [NSString stringWithUTF8String:__TIME__]];
    
        // Convert to date
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"LLL d yyyy HH:mm:ss"];
        NSDate *date = [dateFormat dateFromString:dateStr];
    
        // Set output format and convert to string
        [dateFormat setDateFormat:@"yyMMddHHmm"];
        buildDate = [dateFormat stringFromDate:date];
    
        [dateFormat release];
    
        return buildDate;
    }
    

提交回复
热议问题