【发布时间】:2019-04-06 10:02:11
【问题描述】:
我有一个显示不同国家时区的应用程序。目前代码如下所示:
if indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 6 || indexPath.row == 7{
cell.aseanDate.text = dayFormatter.string(from: Date() as Date)
cell.aseanTime.text = dateFormatter2.string(from: Date() as Date)
cell.aseanTime.textAlignment = .center
cell.aseanTimeZone.text = "\(TimeZone(abbreviation: "UTC+07")!)"
}
时间本身显示正确,但在aseanTimezone.text 下显示GMT +0800(固定)
是否可以更改它以显示 GMT 但没有第一个零和单词(固定)?
【问题讨论】:
-
如果您对时区进行硬编码,那么为什么还要创建
TimeZone实例呢?只需输入您想要的特定字符串即可。 -
不相关但
Date() as Date毫无意义。只需使用Date()。无需将Date转换为Date。