• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

How to add Date and Time to Web page

Q&A Forum › Category: ESP32 › How to add Date and Time to Web page
0 Vote Up Vote Down
Joseph Bauer asked 3 years ago

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);
}

Question Tags: Async Web Server
2 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

I see that you solved the issue: https://rntlab.com/question/how-to-add-date-and-time-to-web-page-2/

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.