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

jackdou-timejs

v0.2.2

Published

javascript smart date package like php date

Downloads

6

Readme

TimeJS

更被 PHP 开发者熟悉的 JS 时间处理库,无额外第三方依赖,小巧快速

Usage

npm install jackdou-timejs

import Time from 'jackdou-timejs'

// 实例化参数和标准库对象 Date 完全一致,可以无缝迁移
const t = new Time()

// 使用UTC时区时间,默认 UTC = false 使用本地时区时间
t.UTC = true

// 格式化日期,layout 参数不传默认为 'Y-m-d H:i:s'
console.log(t.format()) // 2022-08-01 10:00:14

// 支持标准库 Date 的所有 API
// !注意,getMonth 和 getUTCMonth 方法现在不是返回0-11,而是1-12
console.log(t.getMonth()) // 8 表示8月

// 日期计算
t.addYear(1).addMonth(-1).addHours("10").addDays("-30").addMinutes(59).addSeconds(136)

Functions

  • 支持 PHP 模板类型的日期格式化功能

    • 语法: t.format(layout String)
    • 示例:
      • t.format('Y-m-d H:i:s')
      • t.format('y年m月d号 H时i分s秒')
    /**
     * 格式化时间
     * 
     * ------------- 日 ---------------
     * 
     * d	月份中的第几天,有前导零的 2 位数字	01 到 31
     * j	月份中的第几天,没有前导零	1 到 31
     * l(“L”的小写字母)	星期几,完整的文本格式	周日 到 周一
     * N	ISO-8601 格式数字表示的星期中的第几天	1(表示星期一)到 7(表示星期天)
     * z	年份中的第几天	0 到 365
     * 
     * ------------- 星期 --------------
     * 
     * W	ISO-8601 格式年份中的第几周,每周从星期一开始	例如:42(当年的第 42 周)
     * 
     * ------------- 月份 --------------
     * 
     * m	数字表示的月份,有前导零	01 到 12
     * n	数字表示的月份,没有前导零	1 到 12
     * t	指定的月份有几天	28 到 31
     * 
     * ------------- 年 ----------------
     * 
     * L	是否为闰年	如果是闰年为 1,否则为 0
     * Y	4 位数字完整表示的年份	例如:1999 或 2003
     * y	2 位数字表示的年份	例如:99 或 03
     * 
     * ------------- 时间 --------------
     * 
     * g	小时,12 小时格式,没有前导零	1 到 12
     * G	小时,24 小时格式,没有前导零	0 到 23
     * h	小时,12 小时格式,有前导零	01 到 12
     * H	小时,24 小时格式,有前导零	00 到 23
     * i	有前导零的分钟数	00 到 59>
     * s	秒数,有前导零	00 到 59>
     * u	毫秒数 	示例: 654
     * 
    */
  • 支持日期增减

    • API: t.add*()
    • 示例:
      • t.addDays(1)
      • t.addSeconds("-100")

Author

JackDou

License

MIT