在目标c中以自定义格式获取字符串中的当前时间 [英] Getting Current Time in string in Custom format in objective c
本文介绍了在目标c中以自定义格式获取字符串中的当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在字符串中使用以下格式的当前时间。
I want current time in following format in a string.
dd-mm-yyyy HH:MM
dd-mm-yyyy HH:MM
如何?
推荐答案
你想要一个日期格式化程序。这是一个例子:
You want a date formatter. Here's an example:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-MM-yyyy HH:mm"];
NSDate *currentDate = [NSDate date];
NSString *dateString = [formatter stringFromDate:currentDate];
这篇关于在目标c中以自定义格式获取字符串中的当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文