假设我希望日期看起来像这样:
|1988|December|30|
Run Code Online (Sandbox Code Playgroud)
如何将这些添加到dateFormatter或者为此让格式如下:
30 in the month of December in the year of 1998
Run Code Online (Sandbox Code Playgroud)
现在是1988年,12月和30年,我想使用标准格式,但我希望我提出的文字也随之而来.
特别是在上述情况下,格式和管道只是在日期或月份的日期格式旁边,格式和管道之间没有空格.
只需设置格式就可以实现这一切吗?
如何从字符串返回预定义时区的NSDate
let responseString = "2015-8-17 GMT+05:30"
var dFormatter = NSDateFormatter()
dFormatter.dateFormat = "yyyy-M-dd ZZZZ"
var serverTime = dFormatter.dateFromString(responseString)
println("NSDate : \(serverTime!)")
Run Code Online (Sandbox Code Playgroud)
上面的代码返回时间为
2015-08-16 18:30:00 +0000
Run Code Online (Sandbox Code Playgroud)