Forum Moderators: open

Message Too Old, No Replies

How can I get a server time and not local system time in ASP.NET

Servertime in ASP.NET

         

sukumar

12:27 am on Nov 9, 2003 (gmt 0)

10+ Year Member



Hi!

I need some information on how to get the server time and not system time in ASP.Net. When I try this:

<%
dim dtmdate as datetime

dtmdate = datetime.now()

response.write(dtmdate.tostring("f"))

%>

I get the time on my local machine. However, I want the time on the server to be displayed so that the user cannot manipulate the time.

Please help.

Thanks

Sukumar

TheDave

1:04 am on Nov 9, 2003 (gmt 0)

10+ Year Member



<% response.write date() %>

<% response.write time() %>

sukumar

2:40 pm on Nov 10, 2003 (gmt 0)

10+ Year Member



Hi,
I solved this problem of not getting the time from the server by writing this code at the beginning of the code and uploading it to the server. This is very important or else it will give the local machine time.

<script runat="server">

sub page_load
textbox1.text = datetime.now()
end sub
</script>

The textbox1.text is the the textbox in which the time will be displayed.

Thanks for all those who responded.

Bye