Created
March 13, 2018 22:56
-
-
Save rust-play/d8a143e54bce5fd039fa52773a1855c6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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