Coder Social home page Coder Social logo

tonimg / city-country-timezone Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rotimi-best/city-country-timezone

0.0 1.0 0.0 14 KB

Find the timezone from countries given or city and country indicated.

License: MIT License

JavaScript 100.00%

city-country-timezone's Introduction

city-country-timezone

NPM

Find timezone of any country, city or province

About

By passing a country, province or city you would get an object with the timezone of that location you indicated and then the difference in hours between that location you indicated and the location where the code is running (know as time_diff). The location used to test this code is Odessa, Ukraine which would determine the outcome of the time_diff

Getting Started

Installation

npm install city-country-timezone

Code snippet

Search by city

const getTimeDiffAndTimeZone = require('city-country-timezone');

const country = "Los Angeles"; //city

const { timezone, time_diff } = getTimeDiffAndTimeZone(country);

console.log(`Timezone: ${timezone}, Time Difference: ${time_diff}`); 
// Timezone: America/Santiago, Time Difference: -5

Search by region and country

const getTimeDiffAndTimeZone = require('city-country-timezone');

const country = "Samara Region, Russian Federation"; //region and country

const { timezone, time_diff } = getTimeDiffAndTimeZone(country);

console.log(`Timezone: ${timezone}, Time Difference: ${time_diff}`); 
// Timezone: Europe/Moscow, Time Difference: +1

Search by city and country

const getTimeDiffAndTimeZone = require('city-country-timezone');

const country = "Lagos, Nigeria"; //city and country

const { timezone, time_diff } = getTimeDiffAndTimeZone(country);

console.log(`Timezone: ${timezone}, Time Difference: ${time_diff}`); 
// Timezone: Africa/Lagos, Time Difference: -1

city-country-timezone's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.