Convertools Dev
All tools

Unix Timestamp in Rust

Look up the current epoch time and convert between Unix seconds and UTC dates in Rust.

Get the current timestamp

use std::time::{SystemTime, UNIX_EPOCH};

fn main() {
    println!("{}", SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs());
}

Timestamp to date

use chrono::{DateTime, Utc};

fn main() {
    let date = DateTime::<Utc>::from_timestamp(1_700_000_000, 0).unwrap();
    println!("{}", date.to_rfc3339());
}

Date to timestamp

use chrono::DateTime;

fn main() {
    let date = DateTime::parse_from_rfc3339("2023-11-14T22:13:20Z").unwrap();
    println!("{}", date.timestamp());
}

Open 1700000000 in the converter

Current Unix time

Seconds—
Milliseconds—
UTC
—
My time zone
—

Official reference ↗

Free to use. Your input stays in this browser.

How to use it

  1. Copy the current-time example into your Rust environment to read Unix seconds.
  2. Run the second example to display 1700000000 as a UTC date.
  3. Run the last example to convert that date back into seconds.

SystemTime is part of the standard library. These examples use the chrono crate for calendar parsing and formatting. For a time before 1970, duration_since returns an error.