Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created March 13, 2018 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/d8a143e54bce5fd039fa52773a1855c6 to your computer and use it in GitHub Desktop.
Save rust-play/d8a143e54bce5fd039fa52773a1855c6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
extern crate chrono;
use chrono::prelude::*;
fn main() {
let datetime = Utc.ymd(2020, 1, 1).and_hms(0, 0, 0);
let timestamp = datetime.timestamp();
let naive_datetime = NaiveDateTime::from_timestamp(timestamp, 0);
let datetime_again: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
println!("{}", datetime_again);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment