Rust Program to Demonstrate the UTC::Today() And Local::Today() Functions

You are currently viewing Rust Program to Demonstrate the UTC::Today() And Local::Today() Functions

Rust program to demonstrate the Utc::today() and Local::today() functions

// Rust program to demonstrate the 
// Utc::today() and Local::today()
// function

use chrono::prelude::*;

fn main() {
    let dt1 = Utc::today();
    println!("UTC -> Today's date: {}", dt1);
    
    let dt2 = Local::today();
    println!("Local -> Today's date: {}", dt2);
}

Output

$datetime> cargo run
   Compiling datetime v0.1.0 (/home/arvind/Desktop/rust/datetime)
    Finished dev [unoptimized + debuginfo] target(s) in 0.29s
     Running `target/debug/datetime`

UTC -> Today's date: 2021-10-23UTC
Local -> Today's date: 2021-10-23-07:00

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply