TimeZone information

Hello

How do I get the timezone information of the client using Xform. I need to get the timezone information or the GMT offset information. Is there a way to get it ?

Please let me know.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Have you looked at the

Have you looked at the xforms 1.1 date and time functions? .

The local-dateTime() function looks to return the information you require. If you need to be able to access this information in formsPlayer 1.4 version then you can always use some javascript, along the lines of:

...
function show_date_time_offset()
{
	var d = new Date();
	var tz_offset_mins = d.getTimezoneOffset();
	alert("Difference in hours between local time and GMT: " + (tz_offset_mins / 60));
	return (tz_offset_mins / 60);
}
...

You can then call the script (one way of doing so) with an xf:trigger that uses xf:setvalue.

...
<xf:trigger>
	<xf:label>show_date_time_offset()</xf:label>
	<xf:action ev:event="DOMActivate">
		<xf:setvalue 
			ref="/root" 
			value="js:show_date_time_offset()" 
		/>
	</xf:action>
</xf:trigger>
...

If you choose to use the javascript solution, you'll need to also have included the inline script namespace on your forms HTML element, like:

<html
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:xf="http://www.w3.org/2002/xforms"
    xmlns:ev="http://www.w3.org/2001/xml-events" 
    xmlns:js="http://www.formsplayer.com/inlineScript"
...
>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.