I am a brand new beginner, just learning the basics of Javascript.
For days on end, I have been trying to find code that will display the date the webpage was last updated by the web author.
I have used the below function, however, I find the result defaults to UTC/GMT date when using document.lastModified (despite it being formatted to the local date). So the "look" of the date displays OK, but the date is always behind, showing UTC/GMT date, not AEST (Australian Eastern Standard Time).
I tried a few different date options, and below is how the code displays. 'a' and 'b' reference the document.last modified, but the results are not what I want. (When I updated the webpage where I placed my function, my computer clock showed it was Saturday 25 May 2013, 1:45am. (Again, I don't want the current date displayed on the browser, I want so show the date the webpage was last updated by the web author).
Also, I noticed that 'a' is updating the time each instance the browser is refreshed (which is not what I want, I want the date/time returned of the webpage last update by the web author).
This is not the result I want:
Date last updated using 'a': Fri May 24 2013 15:51:06 GMT+1000 (EST)
Date: 24 / Month: 5 / Year: 2013 / Hours: 15 / Minutes: 51 / Seconds: 6
This is not the result I want:
Date last updated using 'b': 24 May 2013
This is for reference/comparison only, showing current date:
Current date using 'c': Sat May 25 2013 01:51:06 GMT+1000 (EST)
Date: 25 / Month: 5 / Year: 2013 / Hours: 1 / Minutes: 51 / Seconds: 6
Code I used:
For days on end, I have been trying to find code that will display the date the webpage was last updated by the web author.
I have used the below function, however, I find the result defaults to UTC/GMT date when using document.lastModified (despite it being formatted to the local date). So the "look" of the date displays OK, but the date is always behind, showing UTC/GMT date, not AEST (Australian Eastern Standard Time).
I tried a few different date options, and below is how the code displays. 'a' and 'b' reference the document.last modified, but the results are not what I want. (When I updated the webpage where I placed my function, my computer clock showed it was Saturday 25 May 2013, 1:45am. (Again, I don't want the current date displayed on the browser, I want so show the date the webpage was last updated by the web author).
Also, I noticed that 'a' is updating the time each instance the browser is refreshed (which is not what I want, I want the date/time returned of the webpage last update by the web author).
This is not the result I want:
Date last updated using 'a': Fri May 24 2013 15:51:06 GMT+1000 (EST)
Date: 24 / Month: 5 / Year: 2013 / Hours: 15 / Minutes: 51 / Seconds: 6
This is not the result I want:
Date last updated using 'b': 24 May 2013
This is for reference/comparison only, showing current date:
Current date using 'c': Sat May 25 2013 01:51:06 GMT+1000 (EST)
Date: 25 / Month: 5 / Year: 2013 / Hours: 1 / Minutes: 51 / Seconds: 6
Code I used:
function dateUpdated() {
a = new Date(document.lastModified)
b = a.toLocaleDateString()
c = new Date
document.write ( "Date last updated using 'a': " + a + "<br>" +
" Date: " + a.getDate() + " / Month: " + (a.getMonth()+1) + " / Year: " + a.getFullYear() + " / Hours: " + a.getHours() + " / Minutes: " + a.getMinutes() + " / Seconds: " + a.getSeconds() + "<p>")
document.write ( "Date last updated using 'b': " + b + "<p>" )
document.write ( "Current date using 'c': " + c+ "<br>" +
" Date: " + c.getDate() + " / Month: " + (c.getMonth()+1) + " / Year: " + c.getFullYear() + " / Hours: " + c.getHours() + " / Minutes: " + a.getMinutes() + " / Seconds: " + c.getSeconds() + "<br>")
}


