✓tick.pro

Unix Timestamp in Any Language — Bash, Python, Go | tick.pro

Copy-paste snippets to get, convert, and print Unix timestamps in Bash, Python, JavaScript, Go, Rust, PHP, Java, C#, Ruby, PostgreSQL, and MySQL.

Three operations, twelve languages, all in UTC so the results match every other tool on this site.

Bash (Linux, GNU coreutils)

Now → epochdate +%s
Epoch → datedate -u -d @1700000000
Date → epochdate -u -d "2024-01-15 10:30:00" +%s

Bash (macOS, BSD date)

Now → epochdate +%s
Epoch → datedate -u -r 1700000000
Date → epochdate -u -j -f "%Y-%m-%d %H:%M:%S" "2024-01-15 10:30:00" +%s

Python

Now → epochimport time; int(time.time())
Epoch → datedatetime.fromtimestamp(1700000000, tz=timezone.utc)
Date → epochint(datetime(2024, 1, 15, 10, 30, tzinfo=timezone.utc).timestamp())

JavaScript

Now → epochMath.floor(Date.now() / 1000)
Epoch → datenew Date(1700000000 * 1000).toISOString()
Date → epochMath.floor(new Date('2024-01-15T10:30:00Z') / 1000)

Go

Now → epochtime.Now().Unix()
Epoch → datetime.Unix(1700000000, 0).UTC()
Date → epochtime.Date(2024, 1, 15, 10, 30, 0, 0, time.UTC).Unix()

Rust

chrono crate
Now → epochSystemTime::now().duration_since(UNIX_EPOCH)?.as_secs()
Epoch → datechrono::DateTime::from_timestamp(1700000000, 0)
Date → epochUtc.with_ymd_and_hms(2024, 1, 15, 10, 30, 0)?.timestamp()

PHP

Now → epochtime()
Epoch → datedate('c', 1700000000)
Date → epochstrtotime('2024-01-15 10:30:00 UTC')

Java (java.time)

Now → epochInstant.now().getEpochSecond()
Epoch → dateInstant.ofEpochSecond(1700000000)
Date → epochLocalDateTime.of(2024, 1, 15, 10, 30).toInstant(ZoneOffset.UTC).getEpochSecond()

C#

Now → epochDateTimeOffset.UtcNow.ToUnixTimeSeconds()
Epoch → dateDateTimeOffset.FromUnixTimeSeconds(1700000000)
Date → epochnew DateTimeOffset(2024, 1, 15, 10, 30, 0, TimeSpan.Zero).ToUnixTimeSeconds()

Ruby

Now → epochTime.now.to_i
Epoch → dateTime.at(1700000000).utc
Date → epochTime.utc(2024, 1, 15, 10, 30).to_i

SQL (PostgreSQL)

Now → epochEXTRACT(EPOCH FROM now())::int
Epoch → dateto_timestamp(1700000000) AT TIME ZONE 'UTC'
Date → epochEXTRACT(EPOCH FROM TIMESTAMP '2024-01-15 10:30:00' AT TIME ZONE 'UTC')

SQL (MySQL)

Now → epochSELECT UNIX_TIMESTAMP();
Epoch → dateSELECT FROM_UNIXTIME(1700000000);
Date → epochSELECT UNIX_TIMESTAMP('2024-01-15 10:30:00');

Frequently Asked Questions

How do I get the current Unix timestamp?

It depends on the language: date +%s in Bash, int(time.time()) in Python, Math.floor(Date.now() / 1000) in JavaScript, time.Now().Unix() in Go. This page shows all three directions — now to epoch, epoch to date, and date to epoch — for a dozen languages side by side.

Are the snippets UTC?

Yes. Every snippet on this page produces or consumes UTC values so the answers match what tick.pro and most APIs expect. Drop the UTC flag or tz argument if you deliberately want local wall-clock time.

curl https://tick.pro/formats/epoch-in-languages