skywinder / ActionSheetPicker-3.0

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.
http://skywinder.github.io/ActionSheetPicker-3.0
BSD 3-Clause "New" or "Revised" License
3.4k stars 740 forks source link

Not able to get exact date #377

Closed ghost closed 4 years ago

ghost commented 6 years ago

Here am trying to pick some date from date picker. suppose i picked 2018-02-05 from action sheet. but in output am getting 2018-02-04. here is the following code i tried. In print(value), i got following output Output: 2018-02-04 18:30:00 +0000

func dateAndTimePicker(_ sender: Any){
        let datePicker = ActionSheetDatePicker(title: "Date", datePickerMode: UIDatePickerMode.date, selectedDate: NSDate() as Date!, doneBlock: {
            picker, value, index in
            print(value) 

            return
        }, cancel: { ActionStringCancelBlock in return }, origin: (sender as AnyObject).superview!?.superview)
        datePicker?.show()
}
xjki commented 6 years ago

By printing Date() you get datetime description relative to GMT timezone. Could it be that 2018-02-04 18:30:00 GMT is 2018-02-05 in your timezone?

skywinder commented 4 years ago

Feel free to reopen the issue, if you still need help. 👍