expression
Chrono RFC 3339 output precision
Select fractional-second output precision and UTC suffix deliberately when a protocol requires a stable format. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 1970-01-01T00:00:00.123Z Common mistake: Assuming every formatted timestamp has the same precision.
Formal Syntax & Structure
rust syntaxrust
to_rfc3339_opts(SecondsFormat::Millis, use_z)Working Example
Example Snippetrust
fn main() { use chrono::{DateTime, SecondsFormat, Utc}; let t = DateTime::from_timestamp(0, 123_000_000).unwrap(); let t = t.with_timezone(&Utc); println!("{}", t.to_rfc3339_opts(SecondsFormat::Millis, true));}