I simply want to retrieve the current Time and Date and store it in a variable. For this I tried to use the chrono::DateTime.
In the documentation I found this:
use chrono::{DateTime, TimeZone, NaiveDateTime, Utc}; let dt = DateTime::<Utc>::from_utc(NaiveDate::from_ymd(2016, 7, 8).and_hms(9, 10, 11), Utc);
This lets me store a specific Date and Time but I couldnt figure how to retrieve the actual current date and time and put it in my DateTime-Variable.
You can get the current date and time in the UTC time zone ( Utc::now() ) or in the local time zone ( Local::now() ). Alternatively, you can create your own date and time.
Use rust, use it now
:
use chrono; fn main() { println!("{:?}", chrono::offset::Local::now()); println!("{:?}", chrono::offset::Utc::now()); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With