rfm
(Randy Meinert)
October 27, 2018, 5:38pm
1
This code from arcLab presents a simple date & time on a page:
<p>Date/Time: <span id="datetime"></span></p> //put on the page
<script> //put in the header
var dt = new Date();
document.getElementById("datetime").innerHTML = dt.toLocaleString();
</script>
But, of course, it doesn’t work:
instacks
(Jannis from inStacks Software)
October 27, 2018, 5:52pm
2
If you are able to publish this page, it makes it easier to check what’s wrong. I guess you entered the HTML
part in a wrong way.
swilliam
(scott williams)
October 27, 2018, 6:46pm
4
What I was going to say in the last post, I couldn’t edit for some reason…
Try removing the script tags and putting the js in the JavaScript area, put the html bit in wherever you want the date to show up.
instacks
(Jannis from inStacks Software)
October 27, 2018, 6:55pm
5
You are also able to put the whole content in the HTML Stack, just as is. You don’t have to separate it into Stacks page and header area.
rfm
(Randy Meinert)
October 27, 2018, 8:28pm
6
Thanks for your input. This should be “stupid” simple. I grabbed the code from https://www.arclab.com/en/kb/htmlcss/display-date-time-javascript-php-ssi.html
I simply brought a rudimentary html stack onto a new stacks page, pasted the code (above), then put the script into the header.
I can’t publish the page right now. I re-up’d with GoDaddy for my sites–and trying to save money, the tech had me migrate my websites to a new directory structure. I think something isn’t set right, but I think it’s on his end.
rfm
(Randy Meinert)
October 27, 2018, 8:31pm
7
I’d actually put the script in the header area. I moved it to the javascript area. No change.
instacks
(Jannis from inStacks Software)
October 27, 2018, 8:35pm
8
Put all together into the HTML stack.
swilliam
(scott williams)
October 27, 2018, 8:39pm
9
Did you get rid of the <script> and </script>
rfm
(Randy Meinert)
October 27, 2018, 8:59pm
10
Your solution worked. Now, here’s the thing: is this approach the “right approach” long term for things of this nature?
rfm
(Randy Meinert)
October 27, 2018, 11:05pm
11
THanks for the input. I tried getting rid of the tags - no change.
instacks
(Jannis from inStacks Software)
October 28, 2018, 8:11am
12
That depends on the code. In that case, the JS Code had to be “below” the HTML code.
If you rewrite the JS code, it will work in header also.
rfm
(Randy Meinert)
October 28, 2018, 8:15am
13
Thanks very much for your help.