expression

Chrono date formatting

Formatting changes a date’s textual representation, not its calendar value. Use known format strings and keep parsing rules separate from presentation. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 03.06.2025 Common mistake: Using a localized display string as a universal storage format.

Formal Syntax & Structure

rust syntaxrust
date.format("%Y-%m-%d")

Working Example

Example Snippetrust
fn main() {    use chrono::NaiveDate;    let d = NaiveDate::from_ymd_opt(2025, 6, 3).unwrap();    println!("{}", d.format("%d.%m.%Y"));}
Rust Reference