Reputation: 35
I want to send system timezone to servlet using javascript . How could I do it when I submit a button on JSP ? .
This is javascript code .
<script>
function dateReturn() {
var date = document.getElementById("demo").innerHTML = Date();
return date;
}
</script>
How can I use this script to do above ?
Upvotes: 0
Views: 131
Reputation: 137
try this for retrieve timezone. you can adjust the substring function for retrieve other details from date object.
var d = new Date();
var s = d.toString();
var timezone= s.substring(s.indexOf("(")+1, s.indexOf(")"));
Upvotes: 0
Reputation: 5419
Read the timezone offset and send it as a separate field or combine date and offset together in 1 item and parse it on server side.
var d = new Date()
var n = d.getTimezoneOffset();
Read JavaScript getTimezoneOffset() Method for more information.
Upvotes: 1