How to convert date of string format to another string format in swift(ios)

ABM

I have a string "2020-01-01T00:00:00". How shall I convert it to another string of format "01-Jan-2020" in swift (iOS)?

The conversion is from String to String.

Jaydeep Vora
let inputDate = "2020-01-01T00:00:00"

let dateFmt = DateFormatter()
dateFmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"

if let date = dateFmt.date(from: inputDate) {
    dateFmt.dateFormat = "dd-MMM-yyyy"
    print(dateFmt.string(from: date))
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert date string to another date string format

Convert string of date format to string of another date format

Convert string date to another format C#?

PHP - Convert this string to another date/time format

How do I take string date input and convert it into another format?

How to convert date string which contains time offset to another format?

Convert date string to another format date string in pandas

Convert Date String to another Date string with different format

How to convert a string date in european format to a valid mysql date format?

Convert string to date then format the date

String date format convert to date

How to convert a bash string to date format?

How to convert String to Date without knowing the format?

How to convert number string into date format

How to convert string to date format in QDataWidgetMapper?

how to convert a string date into datetime format in python?

how to convert a string date into datetime format in python?

Oracle: How to convert a string into date format

How to convert string date to specific format?

How to convert a date string to different format

How to Convert String value into date format

How to convert a string variable to date format in SAS?

How to convert a date format within a string?

How to convert a string to a particular date format in Python

How to convert a date string in jquery to a desired format

pyspark how to convert string to date format

How to convert a date to string in format YYYYMMDD?

How to convert string into a date format in spark

How to convert a string to date format in typescript?