Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: Double value cannot be converted to Int because the result would be greater than Int.max [duplicate]

I want to have the integer value of the following floating point value:

var floatingPointValue = NSDate().timeIntervalSince1970 * 1000

I don't care if the integer value of this floating point number is actually an integer or a string.

like image 604
DrCachetes Avatar asked Nov 19 '22 09:11

DrCachetes


1 Answers

Int64 is large enough to hold a time interval of some million years measured in milliseconds:

let milliSeconds = Int64(someDate.timeIntervalSince1970 * 1000)
let milliSecondsString = String(milliSeconds)
like image 59
Martin R Avatar answered May 26 '23 16:05

Martin R