ToolsKitHub

Timestamp Conversion

Current Unix timestamp (seconds)
TimeStamp

What is a Unix timestamp?

The Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), without considering leap seconds.

Human-readable timesecond(s)
1 hour3600
1 day86400
1 week604800
1 month (30.44 days)2629743
1 year (365.24 days)31556926

What will happen on January 19, 2038?

Due to the 32-bit overflow, this day Unix timestamp will stop working. Before that, millions of applications need to adopt new timestamp conventions or migrate to 64-bit systems, which will 'buy more' timestamps.

Obtain Unix timestamp in different programming languages

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