I had the same problem and i this worked for me
You need to set the time zone
formatter.timeZone = NSTimeZone(abbreviation: "GMT+0:00")
More Related Contents:
- How do I get the current Date in short format in Swift
- Convert string to date in Swift
- All dates between two Date objects (Swift)
- Swift 3.0 : Convert server UTC time to local time and vice-versa
- NSDate() or Date() shows the wrong time
- Date Format in Swift
- DateFormatter’s returns nil for specific date strings without time in Swift
- NSDate Comparison using Swift
- Convert string with unknown format (any format) to date
- Get day of week using NSDate
- NSDate timeIntervalSince1970 not working in Swift? [duplicate]
- Measure elapsed time in Swift
- Xcode Swift am/pm time to 24 hour format
- Convert a Date (absolute time) to be sent/received across the network as Data in Swift?
- Using DateFormatter on a Unix timestamp
- NSDate of yesterday
- swift NSDateFormatter not working
- Get current iPhone device timezone date and time from UTC-5 timezone date and time iPhone app?
- Creating an NSDateFormatter in Swift? [closed]
- Convert date string swift
- How do I convert a date/time string into a different date string?
- How to convert String and perform calculation in Swift? [closed]
- Failing cast in Swift from Any? to protocol
- Swift – Get local date and time
- How can I display my App documents in the Files app for iPhone
- How to append elements into a dictionary in Swift?
- How do I modify the background color of a List in SwiftUI?
- How to check if a text field is empty or not in swift
- App Tracking Transparency Dialog does not appear on iOS
- XCode 7.3.1 hangs on “copying swift standard libraries”