Why would javascript document.lastModified stop working, and return current date?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have web pages on Ubuntu that return the lastModified date as part of the displayed text using javascript to create the following:
Last modified: 08/28/2017
That's the actual last-modified date of the web page. But recently, I'm getting the CURRENT date returned instead. I haven't altered the page whatsoever. I've checked, and this is happening to EVERY web page which used to properly return lastModified. I have some of those pages on my Macintosh, and I can summon them from my 'localhost'. They come up with the proper lastModified date, and I've compared a couple of the web pages between the Ubuntu version, and my Macintosh versions, and they are identical in content, creation-date, and last-modified-date.
Does anyone have a clue of what's happening? Below is the JavaScript I used to return just the date portion, leaving off the time portion of lastModified:
Last modified:
<script language="JavaScript">
var testlast=document.lastModified;
testlast=testlast.substr(0,10);
document.write(" "+testlast);
</script>
From Ubuntu, this now produces:
Last Modified: 09/02/2018
On my Mac, it is still producing:
Last modified: 08/28/2017
ubuntu javascript
add a comment |Â
up vote
0
down vote
favorite
I have web pages on Ubuntu that return the lastModified date as part of the displayed text using javascript to create the following:
Last modified: 08/28/2017
That's the actual last-modified date of the web page. But recently, I'm getting the CURRENT date returned instead. I haven't altered the page whatsoever. I've checked, and this is happening to EVERY web page which used to properly return lastModified. I have some of those pages on my Macintosh, and I can summon them from my 'localhost'. They come up with the proper lastModified date, and I've compared a couple of the web pages between the Ubuntu version, and my Macintosh versions, and they are identical in content, creation-date, and last-modified-date.
Does anyone have a clue of what's happening? Below is the JavaScript I used to return just the date portion, leaving off the time portion of lastModified:
Last modified:
<script language="JavaScript">
var testlast=document.lastModified;
testlast=testlast.substr(0,10);
document.write(" "+testlast);
</script>
From Ubuntu, this now produces:
Last Modified: 09/02/2018
On my Mac, it is still producing:
Last modified: 08/28/2017
ubuntu javascript
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have web pages on Ubuntu that return the lastModified date as part of the displayed text using javascript to create the following:
Last modified: 08/28/2017
That's the actual last-modified date of the web page. But recently, I'm getting the CURRENT date returned instead. I haven't altered the page whatsoever. I've checked, and this is happening to EVERY web page which used to properly return lastModified. I have some of those pages on my Macintosh, and I can summon them from my 'localhost'. They come up with the proper lastModified date, and I've compared a couple of the web pages between the Ubuntu version, and my Macintosh versions, and they are identical in content, creation-date, and last-modified-date.
Does anyone have a clue of what's happening? Below is the JavaScript I used to return just the date portion, leaving off the time portion of lastModified:
Last modified:
<script language="JavaScript">
var testlast=document.lastModified;
testlast=testlast.substr(0,10);
document.write(" "+testlast);
</script>
From Ubuntu, this now produces:
Last Modified: 09/02/2018
On my Mac, it is still producing:
Last modified: 08/28/2017
ubuntu javascript
I have web pages on Ubuntu that return the lastModified date as part of the displayed text using javascript to create the following:
Last modified: 08/28/2017
That's the actual last-modified date of the web page. But recently, I'm getting the CURRENT date returned instead. I haven't altered the page whatsoever. I've checked, and this is happening to EVERY web page which used to properly return lastModified. I have some of those pages on my Macintosh, and I can summon them from my 'localhost'. They come up with the proper lastModified date, and I've compared a couple of the web pages between the Ubuntu version, and my Macintosh versions, and they are identical in content, creation-date, and last-modified-date.
Does anyone have a clue of what's happening? Below is the JavaScript I used to return just the date portion, leaving off the time portion of lastModified:
Last modified:
<script language="JavaScript">
var testlast=document.lastModified;
testlast=testlast.substr(0,10);
document.write(" "+testlast);
</script>
From Ubuntu, this now produces:
Last Modified: 09/02/2018
On my Mac, it is still producing:
Last modified: 08/28/2017
ubuntu javascript
ubuntu javascript
edited Sep 3 at 3:32
slmâ¦
239k65494665
239k65494665
asked Sep 2 at 22:39
Dickster
1113
1113
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42
add a comment |Â
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
I believe I've found a solution to the problem of obtaining the 'last modified date' from different servers, either local to the browser, or external. The trick is to combine SSI (server-side instructions) with Javascript within an html document. Here's the code I can insert virtually anywhere in the document:
Last modified:
<script language="JavaScript">
var tconfig = '<!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" -->';
var testlast=document.lastModified;
var tsize=tconfig.length;
if ((tsize > 20) || (tsize < 2))
document.write(" "+testlast.substr(0,10));
else document.write(" "+tconfig);
</script><br />
When the server fetches the document, the SSI instructions are executed, replacing the instructions by the resultant value. Thus, tconfig becomes a string within apostrophes. If the SSI instructions aren't executed, the comment containing the instructions is retained, which is a long string. The variable set has a string size, which can be tested when the JavaScript is executed on the client side (browser). If it is within reasonable bounds, it should be the 'last modified date' determined by the server. If not, then the Javascript tries to determine it from the 'testlast' variable. Either a sub-string of testlast is output, OR the 'tconfig' value is output. Worse case, you'll get today's date from the Javascript's testlast variable.
I'm using this patch in all my documents where I want 'Last modified:' to appear. BTW, notice I used dash in the SSI code, and slash in the Javascript code (default separator). I can then easily distinguish which mechanism provided the value.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I believe I've found a solution to the problem of obtaining the 'last modified date' from different servers, either local to the browser, or external. The trick is to combine SSI (server-side instructions) with Javascript within an html document. Here's the code I can insert virtually anywhere in the document:
Last modified:
<script language="JavaScript">
var tconfig = '<!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" -->';
var testlast=document.lastModified;
var tsize=tconfig.length;
if ((tsize > 20) || (tsize < 2))
document.write(" "+testlast.substr(0,10));
else document.write(" "+tconfig);
</script><br />
When the server fetches the document, the SSI instructions are executed, replacing the instructions by the resultant value. Thus, tconfig becomes a string within apostrophes. If the SSI instructions aren't executed, the comment containing the instructions is retained, which is a long string. The variable set has a string size, which can be tested when the JavaScript is executed on the client side (browser). If it is within reasonable bounds, it should be the 'last modified date' determined by the server. If not, then the Javascript tries to determine it from the 'testlast' variable. Either a sub-string of testlast is output, OR the 'tconfig' value is output. Worse case, you'll get today's date from the Javascript's testlast variable.
I'm using this patch in all my documents where I want 'Last modified:' to appear. BTW, notice I used dash in the SSI code, and slash in the Javascript code (default separator). I can then easily distinguish which mechanism provided the value.
add a comment |Â
up vote
0
down vote
I believe I've found a solution to the problem of obtaining the 'last modified date' from different servers, either local to the browser, or external. The trick is to combine SSI (server-side instructions) with Javascript within an html document. Here's the code I can insert virtually anywhere in the document:
Last modified:
<script language="JavaScript">
var tconfig = '<!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" -->';
var testlast=document.lastModified;
var tsize=tconfig.length;
if ((tsize > 20) || (tsize < 2))
document.write(" "+testlast.substr(0,10));
else document.write(" "+tconfig);
</script><br />
When the server fetches the document, the SSI instructions are executed, replacing the instructions by the resultant value. Thus, tconfig becomes a string within apostrophes. If the SSI instructions aren't executed, the comment containing the instructions is retained, which is a long string. The variable set has a string size, which can be tested when the JavaScript is executed on the client side (browser). If it is within reasonable bounds, it should be the 'last modified date' determined by the server. If not, then the Javascript tries to determine it from the 'testlast' variable. Either a sub-string of testlast is output, OR the 'tconfig' value is output. Worse case, you'll get today's date from the Javascript's testlast variable.
I'm using this patch in all my documents where I want 'Last modified:' to appear. BTW, notice I used dash in the SSI code, and slash in the Javascript code (default separator). I can then easily distinguish which mechanism provided the value.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I believe I've found a solution to the problem of obtaining the 'last modified date' from different servers, either local to the browser, or external. The trick is to combine SSI (server-side instructions) with Javascript within an html document. Here's the code I can insert virtually anywhere in the document:
Last modified:
<script language="JavaScript">
var tconfig = '<!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" -->';
var testlast=document.lastModified;
var tsize=tconfig.length;
if ((tsize > 20) || (tsize < 2))
document.write(" "+testlast.substr(0,10));
else document.write(" "+tconfig);
</script><br />
When the server fetches the document, the SSI instructions are executed, replacing the instructions by the resultant value. Thus, tconfig becomes a string within apostrophes. If the SSI instructions aren't executed, the comment containing the instructions is retained, which is a long string. The variable set has a string size, which can be tested when the JavaScript is executed on the client side (browser). If it is within reasonable bounds, it should be the 'last modified date' determined by the server. If not, then the Javascript tries to determine it from the 'testlast' variable. Either a sub-string of testlast is output, OR the 'tconfig' value is output. Worse case, you'll get today's date from the Javascript's testlast variable.
I'm using this patch in all my documents where I want 'Last modified:' to appear. BTW, notice I used dash in the SSI code, and slash in the Javascript code (default separator). I can then easily distinguish which mechanism provided the value.
I believe I've found a solution to the problem of obtaining the 'last modified date' from different servers, either local to the browser, or external. The trick is to combine SSI (server-side instructions) with Javascript within an html document. Here's the code I can insert virtually anywhere in the document:
Last modified:
<script language="JavaScript">
var tconfig = '<!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" -->';
var testlast=document.lastModified;
var tsize=tconfig.length;
if ((tsize > 20) || (tsize < 2))
document.write(" "+testlast.substr(0,10));
else document.write(" "+tconfig);
</script><br />
When the server fetches the document, the SSI instructions are executed, replacing the instructions by the resultant value. Thus, tconfig becomes a string within apostrophes. If the SSI instructions aren't executed, the comment containing the instructions is retained, which is a long string. The variable set has a string size, which can be tested when the JavaScript is executed on the client side (browser). If it is within reasonable bounds, it should be the 'last modified date' determined by the server. If not, then the Javascript tries to determine it from the 'testlast' variable. Either a sub-string of testlast is output, OR the 'tconfig' value is output. Worse case, you'll get today's date from the Javascript's testlast variable.
I'm using this patch in all my documents where I want 'Last modified:' to appear. BTW, notice I used dash in the SSI code, and slash in the Javascript code (default separator). I can then easily distinguish which mechanism provided the value.
answered Sep 4 at 20:23
Dickster
1113
1113
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f466464%2fwhy-would-javascript-document-lastmodified-stop-working-and-return-current-date%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Doesn't javascript run on the client? Are you using the same web browser/client in these situations? What is it?
â Jeff Schaller
Sep 2 at 23:20
Jeff, I think it would be difficult for the client to get the 'last modified date' from a file on a server that isn't where the client (browser) runs. I've tried Firefox, Safari, and Chrome on my Macintosh. Web pages 'served' from the Ununtu machine at Stanford show the current date. Pages from my Macintosh (server & client) show the correct last modified date.
â Dickster
Sep 4 at 3:29
.Furthermore, when I substitute the following in place of javascript, I get a correct response from Stanford, but NOT from my local server. <!--#config timefmt="%m-%d-%Y" --><!--#echo var="LAST_MODIFIED" --> So I'm caught in a dilemma. Javascript works on my local server (apache2), but NOT from Stanford's server. Vice-verse, #config works from Stanford's server, but NOT from my local server.
â Dickster
Sep 4 at 3:42