1. Timestamp to string
///The timestamp is converted into characters and converted to 0000-00-00 00:00+ (NSString *)time_timestampToString:(NSInteger)timestamp{ NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp]; NSDateFormatter *dateFormat=[[NSDateFormatter alloc]init]; [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm"]; NSString* string=[dateFormat stringFromDate:confromTimesp]; return string; }
Turn string
///Date converted to character conversion 0000-00-00 00:00+ (NSString *)time_dateToString:(NSDate *)date{ NSDateFormatter *dateFormat=[[NSDateFormatter alloc]init]; [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm"]; NSString* string=[dateFormat stringFromDate:date]; return string; }
Summarize
The above is the example code of the time stamp (or date) to string for iOS development introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!