Reputation: 173
I am making a Java web application in whcih customers in different countries are required to upload file through a jsp page.I have to deploy this application in Weblogic server.
Now what i want is their local date-time.I dont want server date-time.
What code should I write in my java application to get their local date and time.
Upvotes: 4
Views: 2806
Reputation: 228
Use following JQuery ajax call function.
$.ajax({
type: "POST",
url: "ServletTest",
data: "clientdate=" + new Date()
});
Upvotes: 0
Reputation: 10866
Using JavaScript() use Date() function and you can send it to server using ajax. You can call this javascript and ajax function right during bodyLoad().
Upvotes: 1
Reputation: 7855
You should have a look at this question: Determining a web user's time zone. Please see the answer of "JD Isaacks" with a lot of upvotes.
Than you can pass the timezone "offset" to your Java application through an ajax call and use it to calculate the users local date and time.
Upvotes: 2
Reputation: 2728
The only way to get the clients timestamp is to retrieve it on the client and send it to the server.
Upvotes: 1
Reputation: 10667
It's tough to get time of user/client unless you pass it explicitly in the post/Ajax call.
Capture time in Javascript and then send it to server in http request.
URL : http://www.w3schools.com/jsref/jsref_obj_date.asp
Upvotes: 4