获取当前时间戳
Swift NSDate().timeIntervalSince1970 Go import ( "time" ) int64(time.Now().Unix()) Java System.currentTimeMillis() / 1000 C #include <sys/time.h> // ... struct timeval tv; gettimeofday(&tv, NULL); // 秒: tv.tv_sec // 毫秒: tv.tv_sec * 1000LL + tv.tv_usec / 1000 JavaScript Math.round(new Date() / 1000) Objective-C [[NSDate date] timeIntervalSince1970] MySQL SELECT unix_timestamp(now()) SQLite SELECT strftime('%s', 'now') Erlang calendar:datetime_to_gregorian_seconds(calendar:universal_time())-719528*24*3600. PHP <?php // pure php time(); Python import time time.time() Ruby Time.now.to_i Shell date +%s Groovy (new Date().time / 1000).longValue() Lua os.time() .NET/C# DateTimeOffset.UtcNow.ToUnixTimeSeconds(); Dart (new DateTime.now().millisecondsSinceEpoch / 1000).truncate()