How to format time hours-minutes-seconds in Rust

1 Answer

0 votes
use chrono::Local;

fn main() {
    // Get the current local time
    let current_time = Local::now();

    // Format the time as "HH:MM:SS"
    let formatted_time = current_time.format("%H:%M:%S").to_string();

    println!("Formatted Time: {}", formatted_time);
}


    
/*
run:

Formatted Time: 18:36:11
   
*/

 



answered Jul 22 by avibootz

Related questions

...