Skip to content

Instantly share code, notes, and snippets.

@muhlenXi
Last active November 22, 2018 11:27
Show Gist options
  • Save muhlenXi/e9a506d2b0a94bdc1438a58994216374 to your computer and use it in GitHub Desktop.
Save muhlenXi/e9a506d2b0a94bdc1438a58994216374 to your computer and use it in GitHub Desktop.
NSDateFormatter 格式化参数说明
附:NSDateFormatter格式化参数如下:
G: 公元时代,例如AD公元
yy: 年的后2位
yyyy: 完整年
MM: 月,显示为1-12
MMM: 月,显示为英文月份简写,如 Jan
MMMM: 月,显示为英文月份全称,如 Janualy
dd: 日,2位数表示,如02
d: 日,1-2位显示,如 2
EEE: 简写星期几,如Sun
EEEE: 全写星期几,如Sunday
aa: 上下午,AM/PM
H: 时,24小时制,0-23
K:时,12小时制,0-11
m: 分,1-2位
mm: 分,2位
s: 秒,1-2位
ss: 秒,2位
S:毫秒
常用日期结构:
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd
MM dd yyyy
注意:yyyy是小写的;大写的YYYY的意思有些不同——“将这一年中第一周的周日当作今年的第一天”,因此有时结果和yyyy相同,有时就会不同。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment