I'm using the chrono crate; after some digging I discovered the DateTime
type has a function timestamp()
which could generate epoch time of type i64
. However, I couldn't find out how to convert it back to DateTime
.
extern crate chrono;
use chrono::*;
fn main() {
let date = chrono::UTC.ymd(2020, 1, 1).and_hms(0, 0, 0);
println!("{}", start_date.timestamp());
// ...how to convert it back?
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…