EpochMasters Logo
Development6 min readJul 10, 2026

High Precision Timestamps: Milliseconds, Microseconds, & Nanoseconds

Not all timestamps are created equal. Understand the differences and how to parse sub-second accuracy in JavaScript and Go.

Why Sub-Second Precision Matters

In modern distributed systems, high throughput database operations, and high-frequency trading, one second is an eternity. A single server can process tens of thousands of transactions per second. Measuring time only in seconds would make it impossible to sort logs chronologically or detect race conditions.

Precision Breakdown

  • Seconds (s): 10^0 (standard Unix time)
  • Milliseconds (ms): 10^-3 (1,000 per second) - standard in JavaScript's Date.now()
  • Microseconds (µs): 10^-6 (1,000,000 per second) - standard in database logging and system metrics
  • Nanoseconds (ns): 10^-9 (1,000,000,000 per second) - used in low-latency systems and kernel scheduling

Working with Nanoseconds in Go

Go provides built-in support for nanosecond-level measurements. The time package is highly optimized for precise clock intervals.

go
package main
import (
    "fmt"
    "time"
)
func main() {
    now := time.Now()
    nanosec := now.UnixNano()
    microsec := now.UnixMicro()
    fmt.Printf("Microseconds: %d\n", microsec)
    fmt.Printf("Nanoseconds:  %d\n", nanosec)
}

JavaScript Precision Limits

In browsers and Node.js, standard JavaScript floats can lose precision. High-resolution timestamps are measured using performance.now() which offers microsecond precision relative to the start of the page load, rather than the global epoch.

javascript
// Browser High Resolution Time
const start = performance.now();
doHeavyWork();
const end = performance.now();
console.log(`Execution time: ${end - start} ms (microsecond precision)`);