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 🙏

© 2025 – Pkg Stats / Ryan Hefner

date-master

v0.1.0

Published

Date Utils

Readme

Date-Master

Date Utils

JavaScript Style Guide

Getting Started

Installation

yarn add date-master
  or
npm i date-master -S

Methods

|key |params |description | |-----------------|-------------|---------------| |getFullYear() | |获取完成年份 | |getMonth() |Boolean |获取月份, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getDate() |Boolean |获取日, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getDay() |Boolean |获取天, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getHours() |Boolean |获取小时, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getMinutes() |Boolean |获取分钟, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getSeconds() |Boolean |获取秒, 参数表示值小与10时, 是否补0, 如 '01', 默认 false | |getDayName() |String |获取中文${params}几, 默认 星期 | |isSameDay() |Vaild Date Param |是否为同一天, 参数为需要比较的时间,用法参考 Example | |format() |String |格式化时间, 具体用法参考 Example | |getTimeInterval()|Vaild Date Param, Array |获取时间间隔, 第一个参数表示需要比较的时间, 第二个参数表示拼接字符串需要的单位, 具体用法参考 Example | |nativeDate | |实例化传入的参数或传入数组的第一个值 的原生Date对象,可调用Date上任意方法。 if u use this package without babel, i think u may not need this getter |

Example

import DateMaster from 'date-master'

const seconds1 = 1506807200000
const seconds2 = 1507019639139

/** getFullYear */
new DateMaster(seconds1).getFullYear() // 2017

new DateMaster([seconds1, seconds2]).getFullYear() // [2017, 2017]

/** getMonth */
new DateMaster(seconds1).getMonth() // 10

new DateMaster([seconds1, seconds2]).getMonth() // [10, 10]

/** getDate */
new DateMaster(seconds1).getDate() // 1

new DateMaster(seconds1).getDate(true) // '01'

new DateMaster([seconds1, seconds2]).getDate(true) // ['01', '03']

/** getDay */
new DateMaster(seconds1).getDay() // 0

/** getHours */
new DateMaster(seconds1).getHours() // 5
new DateMaster(seconds1).getHours(true) // 05

/** getMinutes */
new DateMaster(seconds1).getMinutes() // 33

/** getSeconds */
new DateMaster(seconds1).getSeconds() // 20

/** getDayName */
new DateMaster(seconds1).getDayName() // '星期日'
new DateMaster(seconds1).getDayName('周') // '周日'
new DateMaster([seconds1, seconds2]).getDayName('周') // ['周日', '周二']

/** isSameDay */
new DateMaster(seconds1).isSameDay(new Date()) // false
new DateMaster(seconds1).isSameDay(new Date(seconds1)) // true

/** format */
new DateMaster(seconds1).format('Y-MM-DD') // '2017-10-01'
new DateMaster(seconds1).format('Y.M.D') // '2017.10.1'
new DateMaster(seconds1).format('Y-M-D HH:II:SS') // '2017-10-1 05:33:20'

/** getTimeInterval */
new DateMaster(seconds1).getTimeInterval('2017-10-20') // [18, 18, 26, 40]
new DateMaster(seconds1).getTimeInterval('2017-10-20', ['天', '小时', '分钟', '秒']) // '18天18小时26分钟40秒')
new DateMaster(seconds1).getTimeInterval(['2017-10-20', '2017-10-22'], ['天', '小时', '分钟', '秒']) // ['18天18小时26分钟40秒', '20天18小时26分钟40秒']

/** Native Date Object */
new DateMaster(seconds1).nativeDate.getMonth() // 9

new DateMaster(seconds1).nativeDate.getDay() // 0

new DateMaster(seconds1).nativeDate.getHours() // 5

new DateMaster(seconds1).nativeDate.toDateString() 'Sun Oct 01 2017'