Rust Program to Demonstrate the And_hms_milli(), And_hms_micro(), and And_hms_nano() Functions

You are currently viewing Rust Program to Demonstrate the And_hms_milli(), And_hms_micro(), and And_hms_nano() Functions

Rust program to demonstrate the and_hms_milli(), and_hms_micro(), and and_hms_nano() functions

// Rust program to demonstrate and_hms_milli(), and_hms_micro(), 
// and and_hms_nano() functions

use chrono::prelude::*;

fn main() {
    let dt1 = Utc.ymd(2016, 10, 23).and_hms_milli(10, 12, 25,50);
    println!("Date time: {}", dt1);
    
    let dt2 = Utc.ymd(2016, 10, 23).and_hms_micro(10, 12, 25,50000);
    println!("Date time: {}", dt2);
    
    let dt3 = Utc.ymd(2016, 10, 23).and_hms_nano(10, 12, 25,50000000);
    println!("Date time: {}", dt3);
}

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`

Date time: 2016-10-23 10:12:25.050 UTC
Date time: 2016-10-23 10:12:25.050 UTC
Date time: 2016-10-23 10:12:25.050 UTC

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