extern crate time; fn main() { match time::strptime("2014-03-10 11:20:34.3454", "%Y-%m-%d %H:%M:%S.%f") { Ok(v) => println!("{}", time::strftime("%Y/%m/%d %H:%M:%S.%f", &v).unwrap()), Err(e) => println!("Error: {}", e), }; }
Output:
2014/03/10 11:20:34.345400000
strptime() and strftime() quite useful when using time values. In addition, they usually work in most languages, so learning it once pays well over time.
Sean perry
source share