Timestamp Converter: 10 & 13-Digit Unix Timestamp to Date
Convert timestamps to dates, dates to timestamps, and switch between UTC and UTC+8. 10-digit values are treated as seconds, 13-digit as milliseconds.
Timestamp to Date: 10-Digit Seconds & 13-Digit Milliseconds
Unix timestamps count from 1970-01-01 00:00:00 UTC. Use time.Unix to convert a timestamp to a time value; a timezone is required to render a readable date. This page supports the common UTC+8 and UTC+0 zones.
package main
import (
"fmt"
"time"
)
func main() {
unixTime := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
fmt.Println(unixTime.Unix())
t := time.Unix(unixTime.Unix(), 0).UTC()
fmt.Println(t)
}
Timestamp to Beijing Time & UTC
By default the local timezone (the server's configured zone) is used, or you can specify one with FixedZone for the conversion. Format a readable string with time.Format; newer Go versions introduced the handy DateOnly and TimeOnly layouts.
package main
import (
"fmt"
"time"
)
func main() {
loc := time.FixedZone("UTC+8", 8*60*60)
t := time.Date(2009, time.November, 10, 23, 0, 0, 0, loc)
fmt.Println("The time is:", t.Format(time.RFC822))
}
Hive SQL Usage
-- 1. Seconds timestamp to string
SELECT from_unixtime(1709614110, 'yyyy-MM-dd HH:mm:ss') AS time_str;
-- Result: 2024-03-05 14:08:30
-- 2. Milliseconds timestamp to string (divide by 1000 first)
SELECT from_unixtime(cast(1709614110123 / 1000 AS BIGINT), 'yyyy-MM-dd HH:mm:ss') AS time_str;
-- Result: 2024-03-05 14:08:30
Excel Usage
=TEXT((A2/86400000 + 8/24) + DATE(1970,1,1), "yyyy-mm-dd hh:mm:ss")
FAQ
- What's the difference between 10-digit and 13-digit timestamps?
- 10 digits usually means seconds, e.g.
1700000000; 13 digits usually means milliseconds, e.g.1700000000000. - Why is the converted time off by 8 hours?
- Timestamps are based on UTC. Select UTC+8 for Beijing time; storing and transmitting in UTC is generally recommended.
- Can I convert multiple timestamps at once?
- Yes. Click "Batch Convert" above and enter one 10-digit or 13-digit timestamp per line to export the results.
Feedback