秒
北京时间
北京时间
秒
1use std::time::{SystemTime, UNIX_EPOCH};
2
3fn main() {
4 match SystemTime::now().duration_since(UNIX_EPOCH) {
5 Ok(n) => {
6 let unix_timestamp = n.as_secs();
7 println!("current UNIX timestamp: {}", unix_timestamp);
8 },
9 Err(_) => panic!("SystemTime before UNIX EPOCH!"),
10 }
11}