Skip to content

Instantly share code, notes, and snippets.

@mykhailokrainik
Created January 15, 2020 11:33
Show Gist options
  • Save mykhailokrainik/b5e5673a1f061c3956746976ec153f67 to your computer and use it in GitHub Desktop.
Save mykhailokrainik/b5e5673a1f061c3956746976ec153f67 to your computer and use it in GitHub Desktop.
Time since the epoch [Rust]
use time;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
let a = time::get_time().sec;
dbg!(&a);
let since_the_epoch = SystemTime::now().duration_since(UNIX_EPOCH)
.expect("Time went backwards").as_secs();
println!("{:?}", since_the_epoch);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment