Sunday, March 3, 2024
HomeiOS DevelopmentUtilizing SWIFT iOS I receivew and fallacious formar for yr ( "yyyy")...

Utilizing SWIFT iOS I receivew and fallacious formar for yr ( “yyyy”) Surprising Date Format, u


I encountered a problem with my SWIFT iOS app the place the perform liable for producing the present date is producing sudden outcomes for some customers. As a substitute of producing the date within the format ‘yyyy-MM-dd’ as meant, it’s outputting ‘####-MM-dd’, with the yr incorrectly showing as ‘0006’. This sudden parsing error has led to discrepancies in date illustration for affected customers, warranting investigation and an answer to make sure correct date era throughout all gadgets.

Operate to generate present date

 func getFormattedDate() -> String {
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd"
 
    return dateFormatter.string(from: Date())
}

Instance

date=2024-02-29 – anticipated – In the present day ( Feb 29 2024) I needs to be receiving this legitimate date

date=0006-02-29 – consequence – however in some scenaries , and for some customers I obtain this one

enter image description here



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments