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
If you redefine __DATE__
and __TIME__
it will make the time update every time you build your app. you won´t need to clean or archive to update the time, just need run the project.
#define DATE [NSString stringWithUTF8String:__DATE__]
#define TIME [NSString stringWithUTF8String:__TIME__]
- (NSString *)getBuildDate {
NSString *buildDate;
// Get build date and time, format to 'yyMMddHHmm'
NSString *dateStr = [NSString stringWithFormat:@"%@ %@", DATE , TIME ];
// Convert to date
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"LLL d yyyy HH:mm:ss"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormat setLocale:usLocale];
NSDate *date = [dateFormat dateFromString:dateStr];
// Set output format and convert to string
[dateFormat setDateFormat:@"dd/MM/yyyy-HH:mm"];
buildDate = [dateFormat stringFromDate:date];
return buildDate;
}