Saturday, May 19, 2018

set up automatic modification/update time for your website

If you want to make the "last updated" info on your website automatically generated, you may use these codes:

the script tag should look like <script type="text/javascript">

also it is preferable to use the dom to insert content into the page, not document.write.

in the head:
PHP:
<script type="text/javascript">onload = function(){
    
document.getElementById("lastModified").innerHTML "Page last changed " document.lastModified.split(" ")[0];
}
</script>
later on in the body:

HTML:
<span id="lastModified"></span>
good read: http://www.quirksmode.org/js/lastmod.html
These are copied from here: https://forums.techguy.org/threads/how-can-i-get-an-automatic-last-updated-in-my-web-page.693929/

No comments:

Post a Comment