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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wedjs/date

v1.0.0-Alpha.7

Published

----

Readme

@wedjs/date


介绍

参考了 PHP 的 date 方法,实现了 时间戳转换为时间格式 的方法。


安装

通过 NPM 安装:

npm i @wedjs/date

或者 直接引用 CDN

<script src="https://cdn.wangerdi.cn/wedjs/date.js"></script>

使用

_.date(format, timestamp)

时间戳转换为时间格式,返回字符串。

参数

| 参数名 | 类型 | 默认值 | 是否必填 | 描述 | | --- | --- | --- | --- | --- | | format | String | | 必填 | 规定输出日期字符串的格式(例:'Y-m-d H:i:s') | | timestamp | Number | 当前时间戳 | 选填 | 规定整数的 Unix 时间戳(精确到毫秒) |

format参数对应的字符
  • d - 一个月中的第几天(从 01 到 31)
  • D - 星期几的文本表示(用三个字母表示)
  • j - 一个月中的第几天,不带前导零(1 到 31)
  • l('L' 的小写形式)- 星期几的完整的文本表示
  • N - 星期几的 ISO-8601 数字格式表示(1 表示 Monday[星期一],7 表示 Sunday[星期日])
  • S - 一个月中的第几天的英语序数后缀(2 个字符:st、nd、rd 或 th。与 j 搭配使用)
  • w - 星期几的数字表示(0 表示 Sunday[星期日],6 表示 Saturday[星期六])
  • z - 一年中的第几天(从 0 到 365)
  • W - 用 ISO-8601 数字格式表示一年中的星期数字(每周从 Monday[星期一]开始)
  • F - 月份的完整的文本表示(January[一月份] 到 December[十二月份])
  • m - 月份的数字表示(从 01 到 12)
  • M - 月份的短文本表示(用三个字母表示)
  • n - 月份的数字表示,不带前导零(1 到 12)
  • t - 给定月份中包含的天数
  • L - 是否是闰年(如果是闰年则为 1,否则为 0)
  • Y - ISO-8601 标准下的年份数字
  • y - 年份的两位数表示
  • a - 小写形式表示:am 或 pm
  • A - 大写形式表示:AM 或 PM
  • g - 12 小时制,不带前导零(1 到 12)
  • G - 24 小时制,不带前导零(0 到 23)
  • h - 12 小时制,带前导零(01 到 12)
  • H - 24 小时制,带前导零(00 到 23)
  • i - 分,带前导零(00 到 59)
  • e - 分,不带前导零(0 到 59)
  • s - 秒,带前导零(00 到 59)
  • c - 秒,不带前导零(0 到 59)
  • u - 微秒
  • I(i 的大写形式)- 日期是否是在夏令时(如果是夏令时则为 1,否则为 0)
示例
_.date('Y-m-d H:i:s', 1577808000000); // "2020-01-01 00:00:00"
_.date('y-n-j G:e:c (l)', 1577808000000); // "20-1-1 0:0:0 (Wednesday)"