I’m in the ESP8266 Web Server book on page 125.The sample code is:
<script>
var todays_date = new Date();
document.getElementById(“dateTime”).innerHTML = todays_date;
</script>
The output is:
Fri Mar 19 2021 00:01:55 GMT-0700 (Pacific Daylight Time)
Except that Pacific time zone is GMT-0800 and the clock time is 11:55PM PDT
What’s going on?
Hi Daniel.
I’m not sure what’s the problem.
What web browser are you using to open the file?
Regards,
Sara
Do you have the right data and time set up on your computer?
Can you try to add the following between the <script> tags:
var offset = new Date().getTimezoneOffset();
console.log(offset);
After opening the file in the browser, press CTRL+Shift+J and see what is printed in the console.
Regards,
Sara
The offset = 420
btw – it would be helpful if the login button redirected to this page rather than to an ad 🙂
Hi.
The result of offset=420 means that your browser assumes that your local time offset is 7 hours and not 8 hours.
When you click on the login button, it redirects to the courses page, right? Do you see something different?
Regards,
Sara
No, but I should.
Fos example, right now I’m on the thread. I got there by clicking the link in the email. Of course, when I arrive here I am not logged in.
It says login to post, so I click login. When I’m done logging in, it should return me to this thread.
In stead, I have to go back to my email, click the link again and then I arrive back here so I can reply. My recollection is that there is an html property called referrer. I i arrive at the login page and the referrer, it should use that as the destination url instead of the courses page, imho.
re the time, my searching suggests to me that this is a javascript issue. Lots of folks ask about their times being off, some by a day, some by an hour. I’m sure it has nothing to do with the tutorial but it confused me untilmI read up a bit on javascript.
Thanks