How to get tomorrows date in Rust

1 Answer

0 votes
use chrono::{Local, Duration};

fn main() {
    // Get the current date and time in the local time zone
    let now = Local::now();

    // Add one day
    let tomorrow = now + Duration::days(1);

    // Extract the date part from the DateTime object
    let tomorrow_date = tomorrow.date_naive();

    println!("Tomorrow's date: {}", tomorrow_date);
}



/*
run:

Tomorrow's date: 2025-04-10

*/

 



answered Apr 9, 2025 by avibootz
...