RosettaCodeData/Task/Date-manipulation/Swift/date-manipulation.swift

13 lines
279 B
Swift
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import Foundation
let formatter = DateFormatter()
formatter.dateFormat = "MMMM dd yyyy hh:mma zzz"
guard let date = formatter.date(from: "March 7 2009 7:30pm EST") else {
fatalError()
}
print(formatter.string(from: date))
print(formatter.string(from: date + 60 * 60 * 12))