JDM*_*JDM 1 nsdateformatter ios swift
在DateFormatter中使用DD和dd有什么区别?搜索时,我没有看到明显的差异..某些日期格式文档显示"DD"和"dd",有些则没有..
我想了解它的不同之处以及它产生以下评论中显示的结果的原因:
let formatter = DateFormatter()
formatter.dateFormat = "MM/DD/YYYY"
print(formatter.string(from: Date())) // 02/32/2017
formatter.dateFormat = "MM/dd/YYYY"
print(formatter.string(from: Date())) // 02/01/2017
Run Code Online (Sandbox Code Playgroud)
DD
是Day of year
dd
是 是Day of the month
有关更多信息,请参见例如
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
归档时间: |
|
查看次数: |
3730 次 |
最近记录: |