Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios-Date类的值与swift中的dateString不同_Ios_Swift_Date - Fatal编程技术网

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”)