[英]how to change the date format in the objective-c
after selecting the date from the date picker, i am getting the date in the format in view like yy/mm/dd . 从日期选择器中选择日期后,我以yy / mm / dd之类的格式获取日期。
i want to the date format in my view like mm/dd/yy. 我想要日期格式在我看来像mm / dd / yy。 how can i do this.
我怎样才能做到这一点。
You can use the following snippet to convert the date to the format you desire. 您可以使用以下代码段将日期转换为所需的格式。 Note that month use uppercase 'MM' in the format:
请注意,月份使用大写的“ MM”格式:
[dateFormatter setDateFormat:@"MM/dd/yy"];
dateString = [dateFormatter stringFromDate:theDate];
For a full list of the formats available, have a look at the Unicode Standard . 有关可用格式的完整列表,请查看Unicode标准 。 With a few minor exceptions, these formats are all supported on the iPhone.
除少数例外,iPhone均支持这些格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.