Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Rust DateTime Formatting Examples With chrono

Just a few date formats I like to use

rust
```cargo
[dependencies]
chrono = "0.4.31"
```

use chrono::prelude::*;

fn main() {
  let date_string = "2003-01-08 04:05:06";
  let dt = NaiveDateTime::parse_from_str(date_string, "%Y-%m-%d %H:%M:%S").unwrap();
  let formats: Vec<(&str, &str)> = vec![
    ("", "%Y-%m-%d %H:%M:%S"),
    ("", "%Y-%m-%dT%H:%M:%S"),
    ("", "%B %Y"),
    ("", "%b %Y"),
  ];
  formats.iter().for_each(|format| 
    {
      println!("{}", format!("{:^24} | {:^25}", format.1, dt.format(format.1)));
    }
  );
}
results start