Swift#
NSDate().timeIntervalSince1970
import (
"time"
)
int64(time.Now().Unix())
Java#
System.currentTimeMillis() / 1000
#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#
Ruby#
Shell#
Groovy#
(new Date().time / 1000).longValue()
Lua#
.NET/C##
DateTimeOffset.UtcNow.ToUnixTimeSeconds();
Dart#
(new DateTime.now().millisecondsSinceEpoch / 1000).truncate()