How to get Browser time

Posted by Thiyagaa under ASP.NET on 1/10/2012 | Points: 10 | Views : 2208 | Status : [Member] | Replies : 3
i am developing web application.
i published my webapplication in the webserver. my webserver is located in india.
both indian & US users will use my project. i have to get & insert user's local machine machine time.
problem here the current user's machine time only returns the webserver time so i am getting indian time for US users.

so any one please tell me how to solve this issue.




Responses

Posted by: MBA Updates on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
1 down vote


I think that an HTTP request does not include any information about the browser/client time, so you're going to need to work around that using javascript somehow. I found an article regarding this issue here.

I can think of a couple of strategies I might use, depending on the circumstances:

1. Grab the client time with javascript on the previous portal page and include it in the request to the target page via form submission.
2. Set the portlet view to a 'Please wait' message on the initial page load and send the client time to the server via an AJAX request. When the request returns, update the portlet view as needed. If you're writing a JSR 286 portlet, the portlet can implement the ResourceServingPortlet interface to provide a hook (i.e. serveResource method) to render markup fragments. For more information, you can download the JSR 286 spec here (Check out chapter 14 on 'Serving Fragments through Portlets').
3. Use portlet preferences to set a default time zone for the portlet. Let users select a different time zone if they choose. This gives you complete control over the time zones you support without depending on the browser or javascript at all. Portlet preferences are described in chapter 17 of the spec mentioned in


http://www.mbaupdates.com/index.aspx

Thiyagaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Qazitanzeel on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
If you are talking about server response time, then it can be handled by
the following code

static int timeout;

protected void Page_Init(object sender, EventArgs e)
{
timeout=Server.ScriptTimeout; // I am saving the response time to a static variable so that i can set it again on unload event
Server.ScriptTimeout = 3600; // This will extend the response time to on hour,

}
protected void Page_UnLoad(object sender, EventArgs e)
{
Server.ScriptTimeout = timeout;

}


Thiyagaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Qazitanzeel on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Sorry about the ist answer, I was reading a question about timeout in another question. so i replied that to you.

This link will help you in this regard
http://stackoverflow.com/questions/179940/c-sharp-convert-utc-gmt-time-to-local-time

Thiyagaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response