如何从Chrono::DateTime中获取年月日组成部分?
How to get the year, month, and date component from Chrono::DateTime?
The documentation 没有说任何关于这个话题。我需要将它转换成 Date<Tz>
吗?即使那样,也没有从中获取年份部分的功能。
let current_date = chrono::Utc::now();
let year = current_date.year(); //this is not working, it should output the current year with i32/usize type
let month = current_date.month();
let date = current_date.date();
no method named `month` found for struct `chrono::DateTime<chrono::Utc>` in the current scope
The documentation 没有说任何关于这个话题。我需要将它转换成 Date<Tz>
吗?即使那样,也没有从中获取年份部分的功能。
let current_date = chrono::Utc::now();
let year = current_date.year(); //this is not working, it should output the current year with i32/usize type
let month = current_date.month();
let date = current_date.date();
no method named `month` found for struct `chrono::DateTime<chrono::Utc>` in the current scope