cancel
Showing results for 
Search instead for 
Did you mean: 

timezone of client to use in STM trafficscript

SOLVED
Highlighted
Contributor

timezone of client to use in STM trafficscript

Hi All,

does anybody already managed to use the clients-timezone within a trafficscript rule?

i know it could be found via javascript-function, but i don't have a idea how to transport this information to STM...

-Jochen

1 REPLY
Contributor

Re: timezone of client to use in STM trafficscript

One example using an external service to map the geoip information into a timezone name or ID.


$ip = request.getRemoteIP();


$lat = geo.getLatitude( $ip );


$long = geo.getLongitude( $ip );



$googlejson = http.request.get( 'https://maps.googleapis.com/maps/api/timezone/json?location='.$lat.','.$long.'&timestamp=0&sensor=fa...' );



$googlehash = json.deserialize( $googlejson );


$timeZoneName = $googlehash['timeZoneName'];


$timeZoneId = $googlehash['timeZoneId'];



log.info( "Time Zone Name: ".$timeZoneName );


log.info( "Time Zone ID: ".$timeZoneId );


*This rule will add the time it will take to look up the information form Google.

**I would read the  The Google Time Zone API - Google Maps API Web Services — Google Developers before use. You may want to get your own key.