Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function strToDate (str, ext ){
If (str = null | str = '') return;
Var arys = new Array ();
Arys = str. split ('-');
Var newDate = new Date (arys [0], arys [1]-1, arys [2], 9, 0, 0 );
If (ext ){
NewDate = new Date (newDate. getTime () + 1000*60*60*24 );
}
Return newDate;
}
Start = "2012-02-24 ";
End = "2012-02-27 ";
Var date = new Date ();
Var start = strToDate (start );
Var end = strToDate (end, false );
// Document. write start. toString ();
Str = "ad 1 ";
Str2 = "Ad 2 ";
If (date> start & date <end ){
Document. write (str );
} Else {
Document. write (str2 );
}
</Script>
It should be noted that this is determined based on the time of the client,
Start = "2012-02-24 ";
End = "2012-02-27 ";
Actually shown in the last two days of the 1949th and 1949th
DEMO code:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-Type "content =" text/html; charset = gb2312 "> <title> display advertisement _ script house in JS for a specific time period </title> <meta name =" keywords "content =" JS advertisement code, CSS navigation menu, FLSH Focus Image Code "/> <meta name =" description "content =" provides you with-JS advertisement code, CSS navigation menu, FLSH Focus Image Code and webpage special effect code "/> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]