How to get Timestamp of the current Date and time in Rust

use chrono;

fn main() {
    // returns DateTime<Local>
    println!("{:?}", chrono::offset::Local::now());

    // returns DateTime<Utc>
    // NOTE: Available on crate feature *clock* only.
    println!("{:?}", chrono::offset::Utc::now());
}

Rust playground


Sources:

chrono::offset::Local#method.now

chrono::offset::Utc#method.now

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)