Avatar
Avatar
Iceman
@swift-6.0.3 import Foundation let text = "2024-12-03T15:28:23.934 +09:00" let timestampFormat = Date.ISO8601FormatStyle(includingFractionalSeconds: true) let formatter = ISO8601DateFormatter() formatter.formatOptions.insert(.withFractionalSeconds) print(try? Date(text, strategy: timestampFormat)) print(formatter.date(from: text)) (edited)
nil Optional(2024-12-03 06:28:23 +0000)<stdin>:6:7: warning: expression implicitly coerced from 'Date?' to 'Any' 4 | let formatter = ISO8601DateFormatter() 5 | formatter.formatOptions.insert(.withFractionalSeconds) (edited)
1.09 KB