Created
May 1, 2019 06:55
-
-
Save jweinst1/0f0f2e9e31e487469e5367d42ad29253 to your computer and use it in GitHub Desktop.
Using rust to get the unix time in seconds as a number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::{SystemTime}; | |
fn get_sys_time_in_secs() -> u64 { | |
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { | |
Ok(n) => n.as_secs(), | |
Err(_) => panic!("SystemTime before UNIX EPOCH!"), | |
} | |
} | |
fn main() { | |
println!("Time is {}", get_sys_time_in_secs()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment