How to get the current date and time in local and UTC in Rust example
May 21, 2022 · 1 min read
This program prints the current date and time in the system and UTC timezone. It uses the Chrono library to access current timestamp-related information. Let’s create a new rust project using cargo command. cargo new dateapp Next, Change the directory to dateapp cd dateapp Add the Chrono dependency in cargo.toml file [dependencies] chrono = "0.4" Now, Run the cargo build command to install all dependencies. cargo build Let’s write a code for the printing date in local and UTC format....