How do I add the date and time to a web page:
ESP32 DHT11/DHT22 Web Server – Temperature and Humidity using Arduino IDE
Start your code here
server.on("/CurrentDate", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain",readDate().c_str());
String readDate(){
showTime();
float tempT = currentDate1;
Serial.print(“Current Date: “);
Serial.println(tempT);
return (tempT);
}
Hi Joseph.
Do you want to display the current date and time on your web server (like a clock?) or the last time the reading was updated (you get that from the ESP32)?
If you get the time from the ESP32, you can take a look at this project: https://randomnerdtutorials.com/esp32-lora-sensor-web-server/ see the LoRa receiver sketch.
Or click here to see the code: https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/ESP32/ESP3_LoRa/LoRa_Receiver_Web_Server/LoRa_Receiver_Web_Server.ino
Alternatively, if you want to display the current date and time on the web server, you can get it using JavaScript. See this example: https://www.arclab.com/en/kb/htmlcss/display-date-time-javascript-php-ssi.html
What errors do you get with your current code?
Regards,
Sara
I see that you solved the issue: https://rntlab.com/question/how-to-add-date-and-time-to-web-page-2/