expression
time crate format descriptions
Enable the parsing and formatting features and use an explicit format description. Its bracketed syntax differs from Chrono’s percent directives. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 09/08/2025 Common mistake: Passing Chrono percent directives to time’s format description parser.
Formal Syntax & Structure
rust syntaxrust
Date::parse(input, format); date.format(format)Working Example
Example Snippetrust
fn main() { use time::{Date, macros::format_description}; let fmt = format_description!("[year]-[month]-[day]"); let d = Date::parse("2025-08-09", fmt).unwrap(); let output = format_description!("[day]/[month]/[year]"); println!("{}", d.format(output).unwrap());}