Skip to content

saketh-kowtha/time-zone-converter

Repository files navigation

Timezone converter

Timezone converter is a webapplication where one can convert specfic time from one time zone to other timezone.

Screenshots

Web view

Web view

Mobile view

Mobile view

Live url

Click here

Local setup

To run this application in local execute the following commands

Clone the repo

git clone https://github.com/saketh-kowtha/time-zone-converter.git

Node modules installation

npm install

Running in local

npm run dev
# Hit http://localhost:3000 from your browser.

API Usage

If you are running in local then DOMAIN url is http://localhost:3000 otherwise https://time-zone-converter.vercel.app/

URL: <DOMAIN>/api/time-zone-converter?ts=1630760210003&from=asia%2FBangkok&to=zulu
Method: GET
Query params:
  ts: Timestramp
  *from: Timezone
  *to: Timezone
  format: Expected date format.

Sample Response:
{
  "ts": "1631440962290",
  "fromTz": "asia/kolkata",
  "toTz": "japan",
  "asia/kolkata": "12-09-2010",
  "japan": "12-09-2010",
  "ISODate": "2021-09-12T10:02:42.290Z",
  "format": "DD-MM-YYYY"
}

Query params

Param Mandatory Description Example Default value
ts NO This is optional if it didn't passed then API will consider current time as ts 1630760210003 Current timestramp
from Yes From timezone Asia%2FCalcutta -
to Yes To timezone Asia%2FCalcutta -
format No Date format (For formats you can use momentjs formats) DD-MM-YYYY ISO 8601, no fractional seconds

Refer this link for formats (format query param)

Using with cURL

curl 'https://time-zone-converter.vercel.app/api/time-zone-converter?ts=1630760210003&from=asia%2FBangkok&to=zulu'

Using with Fetch

fetch('https://time-zone-converter.vercel.app/api/time-zone-converter?ts=1630760210003&from=asia%2FBangkok&to=zulu', {
    body: null,
    method: 'GET',
})
    .then((response) => response.json())
    .then((data) => console.log(data))

Using with Axios

axios
    .get('https://time-zone-converter.vercel.app/api/time-zone-converter?ts=1630760210003&from=asia%2FBangkok&to=zulu')
    .then((response) => console.log(response.data))
    .catch(console.error)

About

Timezone converter is a webapplication where one can convert specfic time from one time zone to other timezone.

Topics

Resources

Stars

Watchers

Forks