Does anyone kown in NodeJS, is there any way, server side script can retrieve client's time zone information from the ServerRequest object?
thanks
From the server request object? The only way I know of is to map the client's IP address, which you can get from:
var ip = request.header('x-forwarded-for');
... to the timezone using something like the geoip module. That module uses mindzone's GeoIP data, which, according to MindZone can provide Timezone strings. I don't know if the module API supports that, but in theory the data is there somewhere. It's just a matter of exposing it. If you need actually timezone time offsets, the time module is probably what you want.
Simpler (and probably more accurate), if you have JS running in the client, use Date.getTimezoneOffset and send that as part of your web request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With