How can I get the current time in milliseconds?
Since Rust 1.8, you do not need to use a crate. Instead, you can use SystemTime and UNIX_EPOCH: use std::time::{SystemTime, UNIX_EPOCH}; fn main() { let start = SystemTime::now(); let since_the_epoch = start .duration_since(UNIX_EPOCH) .expect(“Time went backwards”); println!(“{:?}”, since_the_epoch); } If you need exactly milliseconds, you can convert the Duration. Rust 1.33 let in_ms = since_the_epoch.as_millis(); … Read more