NSDateFormatter&“月&"用3个字母代替完整的单词 [英] NSDateFormatter "Month" in 3 letters instead of full word

查看:205
本文介绍了NSDateFormatter&“月&"用3个字母代替完整的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"dd-MM-YYYY HH:mm"];        
    [formatter setTimeZone:[NSTimeZone systemTimeZone]];

如果我选择MM,我会得到月份的数字:09-05-2012 15:33 如果我选择MMMM,我会得到一个月的单词:09-May-2012 15:33

If i choose MM i get the month in number: 09-05-2012 15:33 If i choose MMMM i get the month in word: 09-May-2012 15:33

我想要的是月份中的3个字母的缩写.
例如:January将是Jan

What i wanted, was the month in 3 letters abbreviation.
Eg: January would be Jan

在这种情况下,May是正确的,因为它只有3个字母.

In this case May is correct because it only has 3 letters.

推荐答案

您是否尝试过:[formatter setDateFormat:@"dd-MMM-YYYY HH:mm"];然后[formatter stringFromDate:someNSDate];

这篇关于NSDateFormatter&“月&"用3个字母代替完整的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆