Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with this cookie? 1

Status
Not open for further replies.
Hello,
In the function When apply the same logic you use in the function Who - if the cookie value is null, to not print the last time - you cannot format or substring something
from null.
D.
 
Thank you, I changed the null to zero, it now shows the correct time, but no year. For what I need the page for, that works. Thank you so much, Zolah
 
My idea was to add a control in function When

// ...
if (WWHTime != null) {
WWHTime = WWHTime * 1
var lastHereFormatting = new Date(WWHTime);
var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
var lastHereInDateFormat = "" + lastHereFormatting;
var dayOfWeek = lastHereInDateFormat.substring(0,3)
var dateMonth = lastHereInDateFormat.substring(4,11)
var timeOfDay = lastHereInDateFormat.substring(11,16)
var year = lastHereFormatting.getYear()
// I've changed above row
var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay + " year =" + year
// print also year
}
else WWHText = "" // this is 0 visit so cookie is null
...
 
I am very new to all this, but I got it to work. Thanks again for you input. This is a final for a javascript class I am taking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top