如前所述,
[[NSDate date] timeIntervalSince1970]返回NSTimeInterval,该持续时间以秒为单位,而不是毫秒。
您可以访问https://currentmillis.com/,了解如何获得所需的语言。这是清单-
ActionScript (new Date()).time
C++ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()
C#.NET DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
Clojure (System/currentTimeMillis)
Excel / Google Sheets* = (NOW() - CELL_WITH_TIMEZONE_OFFSET_IN_HOURS/24 - DATE(1970,1,1)) * 86400000
Go / Golang time.Now().UnixNano() / 1000000
Hive* unix_timestamp() * 1000
Java / Groovy / Kotlin System.currentTimeMillis()
Javascript new Date().getTime()
MySQL* UNIX_TIMESTAMP() * 1000
Objective-C (long long)([[NSDate date] timeIntervalSince1970] * 1000.0)
OCaml (1000.0 *. Unix.gettimeofday ())
Oracle PL/SQL* SELECT (SYSDATE - TO_DATE('01-01-1970 00:00:00', 'DD-MM-YYYY HH24:MI:SS')) * 24 * 60 * 60 * 1000 FROM DUAL
Perl use Time::HiRes qw(gettimeofday); print gettimeofday;
PHP round(microtime(true) * 1000)
PostgreSQL extract(epoch FROM now()) * 1000
Python int(round(time.time() * 1000))
Qt QDateTime::currentMSecsSinceEpoch()
R* as.numeric(Sys.time()) * 1000
Ruby (Time.now.to_f * 1000).floor
Scala val timestamp: Long = System.currentTimeMillis
SQL Server DATEDIFF(ms, '1970-01-01 00:00:00', GETUTCDATE())
SQLite* STRFTIME('%s', 'now') * 1000
Swift* let currentTime = NSDate().timeIntervalSince1970 * 1000
VBScript / ASP offsetInMillis = 60000 * GetTimeZoneOffset()
WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now()) * 1000 - offsetInMillis + Timer * 1000 mod 1000
对于客观CI,请执行以下类似操作以进行打印-
long long mills = (long long)([[NSDate date] timeIntervalSince1970] * 1000.0);
NSLog(@"Current date %lld", mills);
霍普这有帮助。