How to get Timestamp of the current Date and time in Rust?
I Rust, we can get current date and time using structureuse chrono
which has a function called now()
method:Example of now() in Rust
use chrono;
fn main() {
println!("{:?}", chrono::offset::Local::now());
println!("{:?}", chrono::offset::Utc::now());
}
Output
2022-01-30T04:25:52.207241221+00:00
2022-01-30T04:25:52.208492631Z
2022-01-30T04:25:52.208492631Z