Hello All,
I am trying to create a html file that will return the date and time from a web browser.
The goal is to have the ESP start in Access Point Mode (no actual internet access)
send an html file to the client that shows an local date/time, such as:
================== dateTime.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Display current date and time</title>
</head>
<body>
<h1>Current date and time:</h1>
<span id="datetime"></span>
<script>
// create a function to update the date and time
function updateDateTime() {
// create a new `Date` object
const now = new Date();
// get the current date and time as a string
const currentDateTime = now.toLocaleString();
// update the `textContent` property of the `span` element with the `id` of `datetime`
document.querySelector('#datetime').textContent = currentDateTime;
}
// call the `updateDateTime` function every second
setInterval(updateDateTime, 1000);
</script>
</body>
</html>
This code does work.
Now I would like to capture that Date object into variables in the ESP device C code.
I am not a web/script developer.
Thank You for any assistance.
Capture dateTime.html
Re: Capture dateTime.html
You could set up a POST endpoint in your web server (in your C code) which would accept a payload, i.e. your timestamp. Your HTML file would then call this endpoint (from Javascript) using for example an XMLHttpRequest.
https://techtutorialsx.com/2017/03/26/e ... p-request/
https://stackoverflow.com/questions/971 ... ttprequest
https://techtutorialsx.com/2017/03/26/e ... p-request/
https://stackoverflow.com/questions/971 ... ttprequest
Who is online
Users browsing this forum: No registered users and 14 guests