npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

advanced-date-formatter

v0.0.2

Published

An advanced utility for formatting dates.

Downloads

15

Readme

Advanced Date Formatter

advanced-date-formatter is a simple utility for formatting dates in various common formats. This package provides an easy way to convert JavaScript Date objects to formatted date strings using customizable format strings.

Features

  • Format dates in various formats such as YYYY-MM-DD, MM/DD/YYYY, YYYY-MM-DD hh:mm:ss
  • Supports placeholders for year, month, day, hours, minutes, and seconds
  • Works with UTC time to avoid time zone issues

Installation

To install the package, use npm:

npm install advanced-date-formatter

const formatDate = require('advanced-date-formatter');
Usage

Import the formatDate function from the package and use it to format Date objects according to your needs.
Importing the Package

javascript

const formatDate = require('advanced-date-formatter');

Formatting Dates

1. Format to YYYY-MM-DD:

javascript

const date = new Date();
console.log(formatDate(date, 'YYYY-MM-DD')); // Example output: 2024-07-26

2. Format to MM/DD/YYYY:

javascript

const date = new Date();
console.log(formatDate(date, 'MM/DD/YYYY')); // Example output: 07/26/2024

3. Format to YYYY-MM-DD hh:mm:ss:

javascript

const date = new Date();
console.log(formatDate(date, 'YYYY-MM-DD hh:mm:ss')); // Example output: 2024-07-26 14:30:45

4. Format with Single Digit Hour:

javascript

const date = new Date(Date.UTC(2024, 6, 26, 1, 30, 45)); // Month is 0-indexed
console.log(formatDate(date, 'YYYY-MM-DD hh:mm:ss')); // Example output: 2024-07-26 01:30:45

API
formatDate(date, format)

Formats a Date object according to the specified format string.

    Parameters:
        date (Date): The date to format.
        format (string): The format string with placeholders.

    Returns:
        (string): The formatted date string.

Placeholders:

    YYYY: Year (e.g., 2024)
    MM: Month (e.g., 07)
    DD: Day of the month (e.g., 26)
    hh: Hours (24-hour format, e.g., 14)
    mm: Minutes (e.g., 30)
    ss: Seconds (e.g., 45)

Development

To test the package, use:

bash

npm test

This will run the test cases and verify that the package functions correctly.
Contributing

Feel free to contribute to the project by opening issues or pull requests. Make sure to follow the coding standards and write tests for new features.
License

MIT License. See the LICENSE file for details.

Author
karuppusamy.p


### Notes:

1. **Customizable Formats**: This README provides examples of how to use the package to format dates in different formats.
2. **API Documentation**: It describes the `formatDate` function and the placeholders available.
3. **Development and Contribution**: Includes instructions for testing and contributing to the project.
4. **License and Author**: Make sure to update the license and author information as needed.

Feel free to adjust any sections or add more details as needed. Let me know if there are other aspects you'd like to include!