程序代码如下:<script Language="JavaScript" >
window.setTimeout('this.location.reload();',600000);
function timeview()
{
thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds
time_area.innerHTML = thistime;
window.setTimeout( "timeview()", 1000 );
}
</script><td class="small" style="WIDTH: 160px" align="middle" width="25%" height="28">现在时刻:<b><span id="time_area"></span></b></td>
这样取的时间是客户端的时间,请问要怎么改,在能取的服务器的时间啊,我在:<script Language="JavaScript" >加了runat =server也去起作用,我是在aspx页面
window.setTimeout('this.location.reload();',600000);
function timeview()
{
thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds
time_area.innerHTML = thistime;
window.setTimeout( "timeview()", 1000 );
}
</script><td class="small" style="WIDTH: 160px" align="middle" width="25%" height="28">现在时刻:<b><span id="time_area"></span></b></td>
这样取的时间是客户端的时间,请问要怎么改,在能取的服务器的时间啊,我在:<script Language="JavaScript" >加了runat =server也去起作用,我是在aspx页面
DateTime.Now.ToLongTimeString();
DateTime.Now.ToLongDateString();
因为页面是编译完毕之后,才发给客户端的如果要取数据库的时间
就GetDate()
因为是服务器控件,可以获得服务器的时间
public string strCurrYear,strCurrMon,strCurrDay,strCurrHour,strCurrMin,strCurrSec;DbOper db = new DbOper("select getdate() as c1");//DbOper是我作的访问数据库的类
strdate=db.CurrTB.Rows[0]["c1"].ToString(); //db.CurrTB是DataTable类型的变量
nowDate=Convert.ToDateTime(strdate);
strCurrYear=nowDate.Year.ToString();
strCurrMon=nowDate.Month.ToString();
strCurrDay=nowDate.Day.ToString();
strCurrHour=nowDate.Hour.ToString();
strCurrHour=nowDate.Minute.ToString();
strCurrSec=nowDate.Second.ToString();