as the title suggests. I imported chrono 0.4 just like in the documentation Here

And when i ever i call Utc::now() to get current UTC time, i get error that the function now() doesn't not exists.

Here is my Cargo import:

chrono =  { version = "0.4", default-features = false}

Here is the code snippet to get current UTC time:

        use chrono::prelude::*;

        pub fn get_todays_date(&self) ->  String{
            //let local= Local::now();
            let utc= Utc::now();

When i ever i try to compile this code, i get the following error:

335 |             let utc= Utc::now();
    |                           ^^^ function or associated item not found in `chrono::Utc`

1 Answer 1


I guess you can't use chrono::Utc::now in WASM=) Because it requires std to get the local time of the machine. If you want to get the current time then you need to get the timestamp of the block ink_env::block_timestamp. After you can convert it into Date or Utc and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.