Client side timezone from javascript to server

Client side timezone from javascript to server

I am trying to detect the timezone on the client side (browser through javascript) which i am able to. Now i need to send this to the server for processing.  My Question is "How do i pass the output of javascript variable to outsystems server? " I tried putting a input box with hidden type, but it doesn't work if i want to access the values on the same page. This works if i navigate to other page and access it there.. 

Have anyone of you come across a situation where you want to perform some operations based on the time/timezone on the client side ?
Hi Lokendar,

I'm not sure if I understood your problem but you probably need to call an action so that the value of the variable on server side gets assigned to the input value you just assigned in javascript (e.g. click one ajax hidden button).
On a post request all your input boxes are sent to the server and the variables attached to those inputs are sychonized.

Thanks Hélio for your response.  I have a table with few records on it. One of the column shows the time of the event (server time). I want to compare this event time with the time on the client (i am working on a mobile project) and then disable some records prior to the current time.  The server and the client are on different timezones, so i cannot compare it directly. I would have to get the client timezone and then do the check.  All these happens on page load without any user interactions... 

Hi again Lokendar,

Can't you store the timezone value on a session value on a previous page?

Hi Lokendar,

You can send the timezone offset back to the server through this method (or a variation of it).

First, create an input and make it hidden.

Insert the following JavaScript on the page, in an expression with Escape Content = No and assuming YourInput as the name of the input you've created:

"$(function() {
var ci = document.getElementById('" + YourInput.Id "');
ci.value = (new Date()).getTimezoneOffset();

The code above will wait for the DOM to be ready for manipulation, and then fill in the input's value with getTimezoneOffset of a local date. Note that the timezone offset is provided in minutes (see the documentation for Date.getTimezoneOffset).

When your page's content is submitted, the input will contain the offset value and you'll be able to use it in your server side logic.