开发者

nodejs, how to get client time zone info from its ServerRequest

Does anyone kown in NodeJS, is there any way, server side script can retrieve client's time zone informatio开发者_C百科n 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜