
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
node-google-timezone
Advanced tools
The Time Zone API provides time offset data for locations on the surface of the earth. Requesting the time zone information for a specific Latitude/Longitude pair will return the name of that time zone, the time offset from UTC, and the Daylight Savings offset.
Please refer to The Google Time Zone API documentation for further details on request parameters and response format.
##Installation
npm install node-google-timezone
##Usage
var timezone = require('node-google-timezone');
var timestamp = 1402629305;
// time as seconds since midnight, January 1, 1970 UTC
console.log(new Date(timestamp * 1000));
// => Fri Jun 13 2014 00:15:05 GMT-0300 (BRT)
// somewhere in New York
var lat = 40.7421,
lng = -73.9914;
//timezone.key('YOUR API KEY HERE'); // optional
//timezone.language('es'); // optional: default 'en'
timezone.data(lat, lng, timestamp, function (err, tz) {
console.log(tz.raw_response);
//=> { dstOffset: 3600,
// rawOffset: -18000,
// status: 'OK',
// timeZoneId: 'America/New_York',
// timeZoneName: 'Eastern Daylight Time' }
console.log(tz.local_timestamp);
// => 1402614905
var d = new Date(tz.local_timestamp * 1000);
console.log(d.toDateString() + ' - ' + d.getHours() + ':' + d.getMinutes());
// => Thu Jun 12 2014 - 20:15
});
##API Key
Optional for users of the Free API (2,500 requests per 24 hour period).
Please read the API Key documentation first.
If using a key:
GOOGLE_API_KEY
, or...timezone.key('YOUR-API-KEY');
GOOGLE_CLIENT_KEY
and GOOGLE_SIGNATURE_KEY
, or...timezone.client('YOUR-CLIENT-KEY');
timezone.signature('YOUR-SIGNATURE');
##Parameters
lat
: location latitudelng
: location longitudetimestamp
: time as seconds since midnight, January 1, 1970 UTC. Times before 1970 can be expressed as negative values.callback(err, timezone)
: callback function with an Error
object and a Timezone
object as parameters.timezone.raw_response
: the response as returned by Google API. See Time Zone Responses for more details.{ dstOffset: 3600,
rawOffset: -18000,
status: 'OK',
timeZoneId: 'America/New_York',
timeZoneName: 'Eastern Daylight Time' }
timezone.local_timestamp
: the local time at the specified location considering Daylight Savings Time.timezone.options
:{ location: '40.7421,-73.9914',
timestamp: 1402629305,
language: 'en' }
GOOGLE_API_KEY
timezone.key('YOUR-API-KEY');
GOOGLE_CLIENT_KEY
timezone.client('YOUR-CLIENT-KEY');
GOOGLE_SIGNATURE_KEY
timezone.signature('YOUR-SIGNATURE');
en
timezone.language('pt');
FAQs
A Node.js wrapper to Google Timezone API
The npm package node-google-timezone receives a total of 310 weekly downloads. As such, node-google-timezone popularity was classified as not popular.
We found that node-google-timezone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.