How do you get the timestamp in milliseconds for #include "time.h"?
The way I do it it fees a bit hacky.
#include "time.h"
int64_t timestamp;
int64_t test;
const char* ntpServer = "pool.ntp.org";
unsigned long getTime() {
time_t now;
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
return(0);
}
time(&now);
return now;
}
void setup(){
Serial.begin(115200);
configTime(0, 0, ntpServer);
}
void loop(){
//Get current timestamp
timestamp = getTime();
Serial.print ("time: ");
Serial.println (timestamp);
test = timestamp * 1000;
Serial.print ("test: ");
Serial.println (test);
}