I just read over this post which details that you need to set a locale before the format before attempting to convert a given string back to a date.
I have the below code that follows that format but the conversion from string to date still seems to return nil
though in the playground it seems to work fine.
// originalDate style is the .full style, "Friday, December 10, 2021 at 4:17:04 PM Pacific Standard Time"
let df: DateFormatter = DateFormatter()
df.locale = Locale(identifier: "en_US_POSIX")
df.dateFormat = "MMM d, yyyy" // Sep 12, 2018 format'
let newDate = df.date(from: originalDate)
let newStringDate = df.string(from: newDate!) // throws found nil when unwrapping
What could be causing this?
Edit 1: I'm pulling a string type out of a sqlite db using SQLite.swift