Either use NSDateFormatter
as Carl said, or just use good old strftime
, which is also perfectly valid Objective-C:
#import
time_t currentTime = time(NULL);
struct tm timeStruct;
localtime_r(¤tTime, &timeStruct);
char buffer[20];
strftime(buffer, 20, "%d-%m-%Y %H:%M", &timeStruct);