How to find the difference between 2 NaiveDateTimes?

十年热恋 提交于 2019-11-29 18:49:26

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().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!