Hi Margaret,
These are the constructor available for Date():
new Date()new Date(millisecon ds)new Date(dateString )new Date(yr_num, mo_num,
day_num [, hr_num, min_num, sec_num, ms_num])Parameters
milliseconds Integer value representing the number of milliseconds since 1
January 1970 00:00:00.
dateString String value representing a date. The string should be in a
format recognized by the Date.parse method.
yr_num, mo_num,day_num Integer values representing part of a date. As an
integer value, the month is represented by 0 to 11 with 0=January and
11=December.
as you can see you can set it as you need it, now the tricky part would be
how to transfer the server date to the client, the code below will do it, be
aware I did not test it just write it from OE :)
<%
// Server side code
void WriteDateToClie nt(){
Literal lit = new Literal;
lit.Text = "<script>\n " +
var yr_num=" + DateTime.Now.Ye ar.ToString() + ";\n" +
var mo_num=" + (DateTime.Now.M onth-1).toString() + ";\n"
+ // .Net DateTime.Month is from 1 to 12
var day_num=" + DateTime.Now.Da y.ToString() + ";\n" +
//.. do the same with the Time part
this.Controls.A dd( lit ); // this include the literal in the page control
list
}
%>
//in the client side, you know you have define the variables you are going
to use
<script>
var ServerDate = new Date( yr_num, mo_num, .... );
</script>
Now you have the server time in the client :)
all you have to remember is always call the method in the server side, you
can get this by calling it in the Load handler.
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
----- Original Message -----
From: "sandman" <an*******@devd ex.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
Sent: Tuesday, October 21, 2003 12:44 PM
Subject: Server Time Revisited
I've been testing my web app on another workstation to simulate using
the server time. The test pc's time is an hour behind the server time
and when the user processes a request, the server time is picked up.
The problem is that I've got a "clock" on the web page that updates the
"current time" every second since the app is time critical. The clock
is a jscript routine. It seems to be picking up the local time. I'm
just instantiating a new Date() object (when the page loads), which
according to the docs is making a System.DateTime call. Is there a way
to seed it or get it to pick up the server time instead?
margaret
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!