var millisecondsSince1970: Int64 {
Int64((self.timeIntervalSince1970 * 1000.0).rounded())
}
init(milliseconds: Int64) {
self = Date(timeIntervalSince1970: TimeInterval(milliseconds) / 1000)
}
}
// Today in milliseconds
Date().millisecondsSince1970 // 1641554695757
// The Date for 1 000 000 000 000 milliseconds
print(Date(milliseconds: 1_000_000_000_000)) // 2001-09-09 01:46:40 +0000
Why am I getting "Expressions are not allowed at the top level" error?
Add a Comment