melvitax / DateHelper

A Swift Date extension helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

date from string saving wrong date

ProfoundDonut opened this issue · comments

I'm saving a date, and then converting it to a string. It however displays a date from last year.

Here is my code:

let date = Date(fromString: dateval, format: .custom("MM/dd/YYYY"))

dateval is downloaded from a server, and is equal to 12/21/2019

The output of

 date.toString()

is 12/23/18, 12:00 AM

Thanks in advance for any help!