Date time - static when webpage is saved

Hi and good day,

As a non-scripter, what I want to do is expand the script below, so that the time is also displayed.

The DATE and TIME is kind of static, to be ‘produced’ once the individual webpage is saved and published to the web (document.lastModified).

It is NOT to display the DATE and TIME for the user to observe the current date - time.


the existing script:

<script 
  type="text/JavaScript" 
  language="JavaScript">
<!-- 
//
// format date as yy-mmm-dd
// example: 99, Jan.12
//
function date_ddmmmyy(date)
{
  var d = date.getUTCDate();
  var m = date.getUTCMonth() + 1;
  var y = date.getFullYear() + 2100;

   // handle different year values 
  // returned by IE and NS in 
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }
  
   // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

 // return "" +
 //   (d<10?"0"+d:d) + "-" +
 //   mmm + "-" +
  //  (y<10?"0"+y:y);
//}

return "" +
    (y<10?"0"+y:y) + ", " + mmm + ". " + (d<10?"0"+d:d);
}


//
// get last modified date of the 
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = " " + date_ddmmmyy(new Date(d1));
  }

  return s;
}

//
// finally display the last modified date
// as DD-MMM-YY
//
document.write( 
  "Last modified " + 
  date_lastmodified());

// -->
</script>

The current display of the script looks like this: Last modified 2020, Sep. 16
Even better would be the scientific notation: Last modified UTC 20200916 20:25

Sorry, misread your request. You want to add a published date… I thought you wanted a clock … but if you combine https://www.w3schools.com/jsref/prop_doc_lastmodified.asp with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

Following the article from Chris that might lead somewhere!


An always great read is Chris Ferdinandi:

Hi and good day Max,

Those pages are a good source of info, but to put this together??
I need to declare functions a.s.o.

What I wanted was: LastMod 20200917 06:34 UTC

(or if this is too difficult: LastMod 20200917 08:34 UTC + 2 )

I collected those strips:

<button onclick="myFunction2()">Get lastModified?</button>

<p id="demo"></p>

<!--The button is not needed in this example-->

<script>
//function myFunction2() {
//  var x = document.lastModified;
//  document.getElementById("demo").innerHTML = x;
  
const date = new Date(2019, 1, 1, 1, 1);
const options = {
  year: 'numeric',
  month: 'numeric',
  day: 'numeric',
  timeZoneName: 'long' // I wanted UTC, GMT
  console.log(date.toLocaleDateString('de-DE', options));
};

const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

const options = { year: 'numeric', month: 'numeric', day: 'numeric', time: 'numeric' };

console.log(event.toLocaleDateString('de-DE', options));
// expected output: Donnerstag, 20. Dezember 2012

console.log(event.toLocaleDateString('ar-EG', options));
// expected output: الخميس، ٢٠ ديسمبر، ٢٠١٢

console.log(event.toLocaleDateString(undefined, options));
// expected output: Thursday, December 20, 2012 (varies according to default locale)

// one needs to be chosen, which?
const utcDate1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5));
const utcDate2 = new Date(Date.UTC(0, 0, 0, 0, 0, 0));

console.log(utcDate1.toUTCString());
// expected output: Fri, 02 Feb 1996 03:04:05 GMT

console.log(utcDate2.toUTCString());
// expected output: Sun, 31 Dec 1899 00:00:00 GMT
</script>

If you could help me, I'd be glad to send you coffee cups, how much do you drink?

PS. I also found this link:

Use toLocaleDateString to Format JavaScript Dates

But how to wrap up everything - that's the problem.

/

with best regards, Omar KN, Stockholm, Sweden
omneusr /\ a_t {} outlook || d o t || com

Hopefully someone can chime in here, I'm not a scripter and not from the professional web people.
It would be just very nice to see when one of the page of our site was last modified:

Such as so:
LastMod 20200917 06:34 UTC

/
Any assistance would be greatly appreciated!

With best regards,
Omar KN

(unlisting as this is not related to Hype, as confirmed by @OmarKN )