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

date-utils-2020

v1.1.2

Published

date utils 2020, format(date: Date, formatter: string)/toDate(a?: any)...

Downloads

133

Readme

date-utils-2020

date utils 2020, format(s: any, formatter: string)/toDate(s?: any)...

Note:

When the parameter s is a string: when it is a string of yyyyMMdd/yyyyMM/yyyy, it is processed as yyyyMMdd/yyyyMM01/yyyy0101, and other string numbers are processed as a timestamp.

npm i -S date-utils-2020
# or
yarn add date-utils-2020

Usage

import { formatDate, toDate } from 'date-utils-2020'

const date = toDate('2020-12-04')
console.log(date) 
// Fri Dec 04 2020 09:00:00 GMT+0900 (Japan Standard Time)

const result = formatDate('2020-12-04', 'yyyy/MM/dd W')
console.log(result)
// 2020/12/04 Fri
// node.js
const { formatDate } = require('date-utils-2020')

const result = formatDate(new Date(), 'yyyy/MM/dd hh:mm:ss')
console.log(result)
// 2020/12/05 16:07:43

// timestamp
console.log(formatDate(20210101, 'yyyy-MM-dd hh:mm:ss'))
// 1970-01-01 14:36:50

// yyyyMMdd
console.log(formatDate('20210101', 'yyyy-MM-dd hh:mm:ss g'))
// 2021-01-01 00:00:00 GMT+0900
import { formatDate } from 'date-utils-2020'
constole.log(formatDate(new Date(), 'yyyy/MM/dd hh:mm:ss'))

Methods

|Method|Parameters|Description| |:--|:--|:--| |formatDate|(date: any, format: string, langPackage?: ILangPackage)|return string| |toDate|(s: any)|return Date or null. When the parameter s is a string: when it is a string of yyyyMMdd/yyyyMM/yyyy, it is processed as yyyyMMdd/yyyyMM01/yyyy0101, and other string numbers are processed as a timestamp.|

format

Date Formats, Example yyyy-MM-dd hh:mm:ss W => 2021-01-01 01:01:01 Fri

|format|meaning|Example| |:--|:--|:--| |yyyy/yy|year|2021/21| |MM/M|month|01/1| |dd/d|day|01/1| |hh/h|hour|01/1| |mm/m|minute|01/1| |ss/s|second|01/1| |w|week|[0, 1, 2, 3, 4, 5, 6]| |W|week|['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']| |a|am/pm|am| |A|AM/PM|AM| |g|GMT(Greenwich Mean Time)|GMT+0900| |G|GMT(Greenwich Mean Time)|GMT+0900 (Japan Standard Time), Safari GMT+0900 (JST)|

langPackage

|Props|Type|Description| |:--|:--|:--| |weeks|string[]|Example: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'], Default: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']|

const langPackage = {
  // ['日', '一', '二', '三', '四', '五', '六']
  weeks: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日']
}

formatDate(new Date(), 'yyyy/MM/dd(W) hh:mm:ss', langPackage)
// 2020/12/05(土曜日) 12:22:52