Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们怎样才能得到以下格式的日期/时间: YYYY-MM-DD HH:MM:ss.mmm 实际上,我必须创建一个跟踪类来跟踪iOS设备与另一台设备之间的通信流程。我需要这种格式才能有一个好的时间戳。
它应该是:
NSString *MyString; NSDate *now = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd' 'HH:mm:ss.SSS"]; MyString = [dateFormatter stringFromDate:now];