How do I get the clients date and time in VB.NET?

I am a beginner in web development and I would like to get the clients date time value. If I use DateTime.Now, then I get the date and time from the server point of view. Do you have a solution?


Richard from Maryland.

One thought on “How do I get the clients date and time in VB.NET?

  1. Hi Richard

    What you can do is create a hidden input field. Then write a Javascript routine that executes on the onsubmit event for the form. This routine would populate the hidden field with the time on the client machine. To get the date time information in Java Script Just instantiate a new Date object.

    The hidden field can used with ASP.NET by using the HTML control “HtmlInputHidden” class. You just give you input control a runat=”server” attribute like any other server side control.

    The server can then read out this time when the form posts back. You could even wrap this up in a server control if you need to do this in a number of places.

Comments are closed.