How to Get the Current Date and Time of a Location in Node.JS

Cloudmersive
2 min readNov 20, 2020

When working with international partners or users, perfect timing is necessary. Setting up meetings, sending urgent correspondence, and making phone calls are all dependent upon the date and time at a specific location. For example, if an employee of a US company calls someone at an Australian organization, a Friday afternoon would be poor choice of time as it will already be Saturday in Australia. This API will help mitigate those kinds of risks by retrieving the current date and time of an input location.

To use this API, run this command to install the SDK:

npm install cloudmersive-validate-api-client --save

You can also add this snippet to your package.json:

"dependencies": {
"cloudmersive-validate-api-client": "^1.2.4"
}

Then, you can call the function:

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');
var defaultClient = CloudmersiveValidateApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveValidateApiClient.DateTimeApi();var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.dateTimeGetNowSimple(callback);

This will not only return the time at the desired location, but also the current time in GMT.

You can retrieve the API Key from the Cloudmersive website at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.