import java.time.Instant;
// Timestamp in seconds
System.out.println(Instant.now().getEpochSecond());
// Timestamp in milliseconds
System.out.println(System.currentTimeMillis());Current time
Asia/Shanghai (China Standard Time) · Displayed in the selected time zone
Date/time → timestamp
Enter a date and time to convert it to a timestamp in the selected unit and time zone.
Waiting for input…Timestamp → date/time
Enter a timestamp to convert it to a date and time in the selected time zone.
Waiting for input…Unix Timestamp Converter: Seconds & Milliseconds | FlyJson
Convert Unix timestamps to dates and back in seconds or milliseconds. View current time, switch time zones, batch convert values, and export results to CSV.
What is a Unix timestamp?
A Unix timestamp is the number of seconds or milliseconds since 1970-01-01 00:00:00 UTC. It is commonly used in databases, APIs, logs, scheduled jobs, and expiration checks. A timestamp identifies an instant; a time zone determines how that instant is displayed as a local date and time.
Seconds and milliseconds
Recent dates are commonly represented by 10-digit timestamps in seconds or 13-digit timestamps in milliseconds. One second equals 1000 milliseconds. JavaScript Date.now() and Java System.currentTimeMillis() return milliseconds, while Java Instant.now().getEpochSecond() returns seconds.
For example, 1704081600 seconds and 1704081600000 milliseconds both represent 2024-01-01 12:00:00 in Asia/Shanghai.
Convert timestamps across time zones
Choose a time zone such as Asia/Shanghai, UTC, or America/New_York. The timestamp stays the same when you change zones; only its displayed local date and time changes. Date and time input is interpreted in the selected zone.
Batch conversion
Choose the batch tab and enter one timestamp or date and time per line. Results preserve source line numbers, skip blank lines, and show errors for invalid entries. Copy the results or export the input and output columns to CSV.
Common code examples
JavaScript
// Timestamp in seconds
console.log(Math.floor(Date.now() / 1000));
// Timestamp in milliseconds
console.log(Date.now());Python
import time
# Timestamp in seconds
print(int(time.time()))
# Timestamp in milliseconds
print(int(time.time() * 1000))Go
package main
import (
"fmt"
"time"
)
func main() {
// Timestamp in seconds
fmt.Println(time.Now().Unix())
// Timestamp in milliseconds
fmt.Println(time.Now().UnixMilli())
}MySQL
-- Timestamp in seconds
SELECT UNIX_TIMESTAMP();
-- Timestamp in milliseconds
SELECT TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(3)) DIV 1000;PHP
<?php
// Timestamp in seconds
echo time(), PHP_EOL;
// Timestamp in milliseconds
echo (int) (microtime(true) * 1000), PHP_EOL;C#
using System;
// Timestamp in seconds
Console.WriteLine(DateTimeOffset.UtcNow.ToUnixTimeSeconds());
// Timestamp in milliseconds
Console.WriteLine(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());Ruby
# Timestamp in seconds
puts Time.now.to_i
# Timestamp in milliseconds
puts (Time.now.to_r * 1000).to_iLinux Shell
# Timestamp in seconds
date +%s
# Timestamp in milliseconds (GNU date required)
date +%s%3NFrequently asked questions
Which time zone is selected by default?
Asia/Shanghai is selected by default. You can switch to UTC, Tokyo, New York, and other time zones.
What is the difference between seconds and milliseconds?
One second equals 1000 milliseconds. Select the unit that matches your input before converting.
Which time zone is used to interpret a date and time?
Input dates are interpreted in the selected time zone, and converted dates are displayed in that same zone.
Which formats are supported for batch conversion?
Enter one numeric timestamp or one YYYY-MM-DD HH:mm:ss date and time per line. Blank lines are ignored, and results can be copied or exported as CSV.
How do I get the current Unix timestamp in Java?
Use Instant.now().getEpochSecond() for seconds or System.currentTimeMillis() for milliseconds.