std::time::UNIX_EPOCH - Rust
Description: API documentation for the Rust `UNIX_EPOCH` constant in crate `std`.
Keywords: rust, rustlang, rust-lang, UNIX_EPOCH

# Constant std::time::UNIX_EPOCH 1.8.0 [−] [src]

    pub const UNIX_EPOCH: SystemTime = SystemTime(time::UNIX_EPOCH)

An anchor in time which can be used to create new `SystemTime` instances or learn about where in time a `SystemTime` lies.

This constant is defined to be "1970-01-01 00:00:00 UTC" on all systems with respect to the system clock. Using `duration_since` on an existing `SystemTime` instance can tell how far away from this point in time a measurement lies, and using `UNIX_EPOCH + duration` can be used to create a `SystemTime` instance to represent another fixed point in time.

# Examples

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

    match SystemTime::now().duration_since(UNIX_EPOCH) {
        Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),
        Err(_) => panic!("SystemTime before UNIX EPOCH!"),
    }Run

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
↑
  Move up in search results
↓
  Move down in search results
↹
  Switch tab
⏎
  Go to active search result
+ / -
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)