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

xjp-date-utils

v1.0.0

Published

A simple date utility library for formatting current date in various formats.

Readme

Date Utils

一个简单的日期工具库,提供多种日期格式的获取方法。

安装

npm install xjp-date-utils

使用方法

const dateUtils = require('xjp-date-utils');

// 获取年月日格式 (YYYYMMDD)
const dateOnly = dateUtils.getDateOnly();
console.log(dateOnly); // 例如: 20231013

// 获取年月日时分格式 (YYYYMMDDHHmm)
const dateTime = dateUtils.getDateTime();
console.log(dateTime); // 例如: 202310131430

// 获取年月日时分秒格式 (YYYYMMDDHHmmss)
const dateTimeWithSeconds = dateUtils.getDateTimeWithSeconds();
console.log(dateTimeWithSeconds); // 例如: 20231013143045

// 使用自定义格式
const customFormat = dateUtils.getCurrentDate('dateDash');
console.log(customFormat); // 例如: 2023-10-13

// 使用更灵活的自定义格式化
const formattedDate = dateUtils.formatDate(new Date(), 'YYYY年MM月DD日 HH:mm:ss');
console.log(formattedDate); // 例如: 2023年10月13日 14:30:45

方法说明

getCurrentDate(format)

获取格式化的当前日期

  • format: 格式化类型,可选值:
    • 'date': YYYYMMDD (默认)
    • 'dateSlash': YYYY/MM/DD
    • 'dateDash': YYYY-MM-DD
    • 'dateChinese': YYYY年MM月DD日
    • 'datetime': YYYYMMDDHHmm
    • 'datetimeDash': YYYY-MM-DD HH:mm
    • 'timestamp': YYYYMMDDHHmmss
    • 'timestampDash': YYYY-MM-DD HH:mm:ss
    • 'time': HH:mm:ss
  • 返回值: 格式化后的日期字符串

getDateOnly()

获取年月日格式的日期 (YYYYMMDD)

  • 返回值: 年月日格式的日期字符串

getDateTime()

获取年月日时分格式的日期 (YYYYMMDDHHmm)

  • 返回值: 年月日时分格式的日期字符串

getDateTimeWithSeconds()

获取年月日时分秒格式的日期 (YYYYMMDDHHmmss)

  • 返回值: 年月日时分秒格式的日期字符串

formatDate(date, formatStr)

自定义格式化日期

  • date: 要格式化的日期对象,默认为当前日期
  • formatStr: 格式化字符串,如 'YYYY-MM-DD HH:mm:ss'
  • 返回值: 自定义格式化后的日期字符串

发布到npm

如果您想将此包发布到npm,可以按照以下步骤操作:

  1. 更新package.json中的信息
  2. 运行 npm login 登录您的npm账号
  3. 运行 npm publish 发布包

许可证

ISC