ios-Date类的值与swift中的dateString不同
以下是有关守则:ios-Date类的值与swift中的dateString不同,ios,swift,date,Ios,Swift,Date,以下是有关守则: func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) { formatter.dateFormat = "yyyy MM dd" print("The selecting part") print(date) print(date.d
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
formatter.dateFormat = "yyyy MM dd"
print("The selecting part")
print(date)
print(date.dateTimeString())
}
我得到的结果是:
2018-05-31 15:00:00+0000
2018年6月1日上午12:00:00
我不知道2018-05-31 15:00:00+0000来自哪里,应该是2018-06-01
我想知道这是否是内部错误。有人能给我提供一个解决方案吗?试着设置时区:
formatter.timeZone=timeZone(标识符:timeZone.current.identifier)
我试过了,但没有解决任何问题。什么是dateTimeString()
?代码是什么?date是一个date()类,dateTimeString()是date类的一个属性试试这个:dateFormatter.timeZone=timeZone(缩写:“UTC”)