Code Monkey home page Code Monkey logo

date-util's Introduction

Time Zone Formatter

This module provides a simple utility function to format timestamps into a string representation for different time zones. It's designed to be easy to use for displaying dates and times in the user's local time zone or any specified time zone from around the world.

Features

  • Convert timestamps to a formatted string in various time zones.
  • Supports a wide range of time zones.
  • Easy to integrate into any JavaScript project.

Installation

You can include this module in your project by copying the formatTimestamp function into your codebase. There is no need for npm installation as this is a standalone function.

Usage

To use the formatTimestamp function, simply import it into your JavaScript file and call it with the desired timestamp and time zone.

Parameters

  • timestamp (required): The timestamp you want to format. This should be in milliseconds.
  • timeZone (optional): The IANA time zone identifier string of the desired time zone. Defaults to 'Asia/Shanghai' if not specified.

Example

import { formatTimestamp } from './path/to/timeZoneFormatter';

const myTimestamp = Date.now(); // or any timestamp in milliseconds
const timeZone = 'America/New_York';

const formattedDate = formatTimestamp(myTimestamp, timeZone);
console.log(formattedDate); // Outputs the formatted date and time in the specified time zone

Supported Time Zones

This function supports a variety of time zones, including but not limited to:

  • UTC
  • Europe/London
  • Europe/Berlin
  • Africa/Cairo
  • Asia/Beirut
  • Asia/Dubai
  • Asia/Karachi
  • Asia/Kolkata
  • Asia/Jakarta
  • Asia/Shanghai
  • Asia/Tokyo
  • Australia/Sydney
  • Pacific/Auckland
  • America/Anchorage
  • America/Los_Angeles
  • America/Denver
  • America/Chicago
  • America/New_York
  • America/Caracas
  • America/Sao_Paulo

For a complete list of supported time zones, refer to the TIME_ZONES array in the source code.

License

This project is open-sourced under the MIT License. See the LICENSE file for more details.

Contributing

Contributions to improve the function or extend the list of supported time zones are welcome. Please feel free to submit a pull request or open an issue.


This README provides a basic overview of the Time Zone Formatter module, including how to use it and the features it offers. Adjust the path in the import statement according to your project structure.

date-util's People

Contributors

moncici007 avatar

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.