Capture dateTime.html
Posted: Sat Apr 06, 2024 10:16 pm
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.
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.