@ginojasmingj/user_timezone
v1.0.2
Published
Returns the user's current time in their configured time zone
Downloads
63
Readme
user_timezone
A simple Node.js utility package to get the current time based on a user's time zone.
Installation
npm install user_timezoneUsage
const { currentTime } = require("user_timezone");
// Pass the user's time zone from the database
const userTimeZoneDb = "Asia/Kolkata";
const time = currentTime(userTimeZoneDb);
console.log(time);
// Output: 14:35:20API
currentTime(userTimeZoneDb)
Returns the current time for the specified time zone.
Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| userTimeZoneDb | string | A valid IANA time zone (e.g., "Asia/Kolkata", "America/New_York", "Europe/London"). |
Returns
- Type:
string - Example:
"14:35:20"
Example
const { currentTime } = require("user_timezone");
const userTimeZoneDb = "America/New_York";
console.log(currentTime(userTimeZoneDb));Supported Time Zone Format
Use a valid IANA time zone identifier, such as:
Asia/KolkataAmerica/New_YorkEurope/LondonAustralia/SydneyAfrica/NairobiAsia/Dubai
License
ISC
