NSDateFormatter“月”在3个字母而不是全字 [英] NSDateFormatter "Month" in 3 letters instead of full word

查看:113
本文介绍了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天全站免登陆