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

datex.js

v1.0.12

Published

a datetime format library

Downloads

16

Readme

Nodejs安装datex

npm install datex.js

datex方法说明

getTime() 返回时间戳(毫秒)

datex().getTime()
// => 1670768193313

getUnix() 返回时间戳(秒)

datex().getUnix()
// => 1670768193

clone() 返回克隆对象

datex().clone()

toDate() 返回原生Date对象

datex().toDate()
// => Sun Dec 11 2022 22:20:20 GMT+0800 (中国标准时间)

toObject() 返回时间字段对象

datex().toDate()
// => {
	year:2022,
	month:12,
	day:11,
	hour:22,
	minute:23,
	second: 14,
	millsecond:612,
	timestamp:1670768594612,
	week:0
}

toArray() 返回时间字段数值

datex().toArray()
// => [2022,12,11,22,23,14,612]

toString() 返回字符串

datex().toDate()
// => Sun Dec 11 2022 22:20:20 GMT+0800 (中国标准时间)

toISOString() 返回ISO字符串

datex().toDate()
// => 2023-04-12T07:20:23.363Z

format(pattern) 返回格式化时间

datex(2022,10,1).format('YYYY-MM-DD HH:mm:ss')
// => 2022-10-01 00:00:00

datex(1671761818503).format('YYYY/MM/DD')
// => 2022/12/23

set(name,value) 设置某字段值

datex(2022,10,1).set('year',2020).format()
// => 2020-10-01 00:00:00

change(name,value) 增减某字段值

datex(2022,10,1).change('year',1).format()
// => 2022-10-01 00:00:00

startOf(name) 获取某字段起始时

datex(2022,10,10).startOf('month').format()
// => 2022-10-01 00:00:00

endOf(name) 获取某字段末尾时

datex(2022,10,10).endOf('month').format()
// => 2022-10-31 23:59:59

get(name) 返回某字段值

datex(2022,10,1).get('year')
// => 2022

diffWith(dateStr|datex,name) 返回某字段差值

datex('1949-10-01').diffWith('2022-12-01','month')
// => -878

isBefore(dateStr|datex,name) 是否在某个时间点之前

datex('2008-08-08').isBefore('2022-02-02')
// => true

isAfter(dateStr|datex,name) 是否在某个时间点之后

datex('2008-08-08').isAfter('2022-02-02')
// => false

isSame(dateStr|datex,name) 是否和某个时间点相等

datex('2008-08-08').isSame('2022-02-02')
// => false

isBetween(dateStr|datex,dateStr|datex,name) 是否在两个时间点之间

datex('2008-08-08').isBetween('2003-07-13','2022-02-02')
// => true