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

@youmaole/easy-date-time

v1.0.6

Published

A small tool for handling the normal date & time operations

Downloads

19

Readme

easy-date-time

A small tool for date & time operations.

Install

  • npm i @youmaole/easy-date-time
  • yarn add @youmaole/easy-date-time

Import

import { now, format, toUtc, toLocal, addDays, addMonths } from '@youmaole/easy-date-time';

Usage

Methods for getting now: now(option?)

  • Format 1: now() // 2021-03-20 20:22:09
  • Format 2: now('-') // 2021-03-20 20:22:09
  • Format 3: now('/') // 2021/03/20 20:22:09
  • Format 4: now('ts') // 1616242929298
  • Format 5: now('timestamp') // 1616242929298
  • Format 6: now('time') // 20:22:09
  • Format 7: now('t') // 20:22:09

Methods for date/time format: format(date_input, option?)

  • Format 1: format('2021-03-20') // 2021-03-20 08:00:00
  • Format 2: format('2021-03-20', 'yyyy-mm-dd') // 2021-03-20
  • Format 3: format('2021-03-20', 'yyyy-mm-dd hh:mm:ss') // 2021-03-20 08:00:00
  • Format 4: format('2021-03-20', 'yyyy-mm-dd h:m:s') // 2021-03-20 08:00:00
  • Format 5: format('2021-03-20', 'yyyy/mm/dd') // 2021/03/20
  • Format 6: format('2021-03-20', 'yyyy/mm/dd hh:mm:ss') // 2021/03/20 08:00:00
  • Format 7: format('2021-03-20', 'yyyy/mm/dd h:m:s') // 2021/03/20 08:00:00
  • Format 8: format('2021-03-20', 'yy-mm-dd') // 21-03-20
  • Format 9: format('2021-03-20', 'yy/mm/dd') // 21/03/20
  • Format 10: format('2021-03-20', 'yyyymmdd') // 20210320
  • Format 11: format('2021-03-20', 'yymmdd') // 210320
  • Format 12: format('2021-03-20', 'hh:mm:ss') // 08:00:00
  • Format 13: format('2021-03-20', 'h:m:s') // 08:00:00
  • Format 14: format('2021-03-20', 'time') // 08:00:00
  • Format 15: format('2021-03-20', 't') // 08:00:00
  • Format 16: format('2021-03-20', 'hh:mm') // 08:00
  • Format 17: format('2021-03-20', 'h:m') // 08:00
  • Format 18: format('2021-03-20', 'mm:ss') // 00:00
  • Format 19: format('2021-03-20', 'm:s') // 00:00
  • Format 20: format('2021-03-20', 'ts') // 1616198400000
  • Format 21: format('2021-03-20', 'timestamp') // 1616198400000

Methods for UTC format: toUtc(local_date_input)

  • Local to UTC: toUtc('2021-03-20') // 2021-03-20 00:00:00 toLocal(utc_date_input)
  • UTC to local: toLocal('2021-03-20 00:00:00') // 2021-03-20 08:00:00

Methods for adding days: addDays(date_input, days?)

  • Default add 0 day: addDays('2021-03-20') // 2021-03-20 08:00:00
  • Other days: addDays('2021-03-20', 5) // 2021-03-25 08:00:00

Methods for adding months: addMonths(date_input, months?)

  • Default add 0 month: addMonths('2021-03-20') // 2021-03-20 08:00:00
  • In this year: addMonths('2021-03-20', 5) // 2021-08-20 08:00:00
  • Out of this year: addMonths('2021-03-20', 15) // 2022-06-20 08:00:00

Methods for adding years: addYears(date_input, years?)

  • Default add 0 year: addYears('2021-03-20') // 2021-03-20 08:00:00
  • addYears('2021-03-20', 5) // 2026-08-20 08:00:00

Valid input:

  • date object: new Date()
  • date string: '2021-03-20', '2021/03/20'
  • date string: '2021-03-20 08:00:00'
  • timestamp: 1616245217168