If I print the current time directly, it includes many trailing decimals:
println!("{:?}", chrono::offset::Utc::now());
2022-12-01T07:56:54.242352517Z
How can I get it to print like this?
2022-12-01T07:56:54Z
If I print the current time directly, it includes many trailing decimals:
println!("{:?}", chrono::offset::Utc::now());
2022-12-01T07:56:54.242352517Z
How can I get it to print like this?
2022-12-01T07:56:54Z
Copyright © 2021 Jogjafile Inc.
You can use
to_rfc3339_opts
. It accepts arguments for the format of the seconds and if theZ
should be present.Rust Playground