Detection advertisement display judgment function seen from Sina
Copy codeThe Code is as follows:
<Script>
Pagepubtime = "2006-08-31 ";
// Ad display judgment
Function checkPubTime (){
// Year, month, and day
DateTime = new Array ();
DateTime = pagepubtime. split ("-");
Var year = DateTime [0];
Var month = DateTime [1];
Var day = DateTime [2];
// Use the year, month, or day to generate a date object.
Var pubTime = new Date (year, month-1, day );
// Obtain the current date
Var now = new Date ();
// Calculate the millisecond difference between the current date and the release date
Var dif = now. getTime ()-pubTime. getTime ();
// Date difference to be detected
Var difDay = 180;
// 24 hours per day, 60 minutes per hour, 60 seconds per minute, 1000 milliseconds per second
If (dif> difDay * 24*60*60*1000)
{
Return false;
}
Return true;
}
<SCRIPT>
// <! -- Advertisement publishing -->
<! --
If (checkPubTime ())
{
Document. getElementById ("PublicRelation4"). style. display = "";
}
-->
</SCRIPT>