See code. When I Serial print the datetime it looks fine.
But when I attempt to put it into the JSON document and POST it to a webservice, it comes out looking like this: 44718.42256
#include "time.h"
String returnTime();
{
getLocalTime(&timeinfo);
char timeStringBuff[50];
strftime(timeStringBuff, sizeof(timeStringBuff), "%D %H:%M:%S", &timeinfo);
return timeStringBuff;
}
String datetime;
datetime = returnTime();
Serial.println(datetime); // This prints the date time properly
StaticJsonDocument<200> doc;
doc[String("timestamp")] = datetime;
String requestBody;
serializeJson(doc, requestBody);
int httpResponseCode = http.POST(requestBody); // this is where the document gets POST'd