ropg / ezTime

ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
MIT License
327 stars 92 forks source link

Unix millisecond timestamp. #62

Closed eskhisov closed 4 years ago

eskhisov commented 4 years ago

Is there a way to get Unix millisecond timestamp? Documentation says that the Unix epoch time returned by now() is in seconds by default. I guess I can get time in RFC3339_EXT format and convert back to epoch, but you already have milliseconds, so it feels kludgy.

eskhisov commented 4 years ago

Ok, this works for me (I need string representation):

  char buffer [3];
  sprintf(buffer,"%03d",ms());
  String milliEpoch = String(now()) + buffer;
danausx commented 3 years ago

Thanks, very helpful.

What happens if ms() is 1000? Or it can only be 999?

ropg commented 3 years ago

ms() can only return values from 0 to 999