"Time" does not name a type


So I wanted to timestamp the data stream which I am sending over the cloud. I used Time.zone() to set the time zone and used Time.now() to get the current unix time. However, at the time of compilation, it is showing an error that Time does not name a type. It was working on the web IDE but seems to generate this error on the desktop IDE.

I have no idea what the issue is.

What device, and DeviceOS are you targeting?
Could you show us your code?

1 Like

I can’t really show you the code.

I’m using photon with the latest OS.

I’ve declared the Time.zone() before the setup function right after the global variables.

You also need to select the target version you want to build for. Just selecting the target device does not automatically set the device OS version.

That’s why we’d need to see the code.
You can’t do that. This is a function call and function calls are not allowed in the declaration/definition section but only inside a function.

1 Like

But it was working in the Web IDE. And this is supposed to be a generic particle library right? Why does it have to work inside another function?

I will try it nonetheless.

I’d tend to doubt that tho’
This is Web IDE and it complains just the same - it has to

Because that is how C/C++ works.


I had the same understanding but it doesn’t seem to be the case.

What doesn’t seem to be the case?
You sait that worked in Web IDE, I contradicted and did show evidence for my contradiction, so my understanding and yours didn’t really align on that matter.


I had the same error and just put Time.zone() in the setup function.

I seem to remember, that it can also happen when you are trying to use Time.now() in a function call that expect variables to be of certain type, such as Particle.publish.