In the tutorial of (www.bkjia.com), some websites are placed at the bottom or sidebar of the webpage, for example, "the website has been running for xx days." Some webmasters asked me how to implement it, in fact, this is not difficult. Let's share the instance code with you.
First look at the HTML section:
Reference content is as follows: <Div class = "yunxing"> The website is running <Span id = "span_dt_dt" style = 'border: 0px solid black; background-color: # ffff'> </span> <SCRIPT language = javascript> <! -- // Document. write (""); Function show_date_time (){ Window. setTimeout ("show_date_time ()", 1000 ); BirthDay = new Date ("07-31-2009"); // the Helper's house prompts: 07-31-2009 indicates the site creation Date. Today = new Date (); Timeold = (today. getTime ()-BirthDay. getTime ()); Sectimeold = timeolder/1000 Secondsold = Math. floor (sectimeold ); MsPerDay = 24*60x60*1000 E_daysold = timeold/msPerDay Daysold = Math. floor (e_daysold ); E_hrsold = (daysold-e_daysold) *-24; Hrsold = Math. floor (e_hrsold ); E_minsold = (hrsold-e_hrsold) *-60; Minsold = Math. floor (hrsold-e_hrsold) *-60 ); Seconds = Math. floor (minsold-e_minsold) *-60 ); Span_dt_dt.innerHTML = daysold + "day" + hrsold + "Hour" + minsold + "Minute" + seconds + "second "; } Show_date_time (); // --> </SCRIPT> </Div> |
The following is the CSS part (put it in the head or css file of the webpage ):
Reference content is as follows: Yunxing {clear: both; text-align: center; border: 1px solid # 0099FF; background: # FFFFFF; line-height: 20px; padding: 6px 5px 3px; color: #666 ;} |