I am using chrono. I have now()
and some other NaiveDateTime
. How can I find a difference between them?
let now = Utc::now().naive_utc();
let dt1 = get_my_naive_datetime();
I am using chrono. I have now()
and some other NaiveDateTime
. How can I find a difference between them?
let now = Utc::now().naive_utc();
let dt1 = get_my_naive_datetime();
Use NaiveDateTime::signed_duration_since
:
println!("{:?}", dt1.signed_duration_since(now))
(playground)
It returns a Duration
, which has &self
-taking methods to yield whatever units you like, e.g. dt1.signed_duration_since(now).num_days()
.