jweinst1
5/1/2019 - 6:55 AM

Using rust to get the unix time in seconds as a number.

Using rust to get the unix time in seconds as a number.

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());
}