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

@iefe/dateformat

v1.0.1

Published

@iefe/dateformat是一款基于UMD模块编译的工具,能够运行在CMD、AMD和浏览器的环境中。工具包仅2k大小,简单安装、使用。

Downloads

7

Readme

介绍

@iefe/dateformat是一款基于UMD模块编译的工具,能够运行在CMD、AMD和浏览器的环境中。工具包仅2k大小,简单安装、使用。

安装


npm i @iefe/dateformat

参数

| 格式 | 说明 | | ---- | ---- | | YYYY | 四位长度的年份0000~9999 | | yy | 两位长度年份00~99 | | Y | 大写四位年份 | | MM | 有前导0的两位月份01~12 | | mm | 无前导0的月份1~12 | | M | 大写月份 | | DD | 有前导0的两位日期01~31 | | dd | 无前导0的日期1~31 | | D | 大写日期 | | hh | 小时 00~23 | | ii | 分钟 00~59 | | ss | 秒 00~59 | | a | 当前时段。上午/下午 | | EEE | 星期 | | EE | EEE星期的别称 周一 周二 |

使用

引入
//es6
import { format } from '@iefe/dateformat' 

//nodejs
const { format } =  require('@iefe/dateformat')

//CDN
<script src="https://unpkg.com/@iefe/[email protected]/dist/dateformat.min.js"></script>
格式化日期时间


//当前时间
format('YYYY-MM-DD hh:ii:ss') 
// 2023-03-10 15:00:00

//一周前的日期
format('-7','YYYY-MM-DD')
// 2023-03-03

//本月1号
format('YYYY-MM-01')


//中文年月日
format('YYYY年MM月DD日')
//2023年03月10日

//大写 年
format('Y年')
// 二零二三年

//大写 月
format('M月')
// 三月

//大写 日
format('D日')
// 十日

//当前时段
format('a')
// 上午

//星期
format('今天EEE')
// 今天星期五
format('今天EE')
// 今天周五


//全部格式
console.log( format(' -7 ','Y年M月D日 YYYY/MM/DD a') )
console.log( format('Y年M月D日 YYYY/MM/DD a') )
console.log( format('Y年M月D日') )
console.log( format('Y年') )
console.log( format('YYYY-MM-DD hh:ii:ss') )
console.log( format('YYYY-MM-DD') )
console.log( format('YYYY-MM-DD hh:ii') )
console.log( format('hh:ii:ss') )
console.log( format('hh:ii:ss a') )
console.log( format('YYYY/MM/DD hh:ii:ss') )
console.log( format('今天EEE') )

方法的调用

console.log('今年剩余:'+getYearLastDays() + '天')
console.log('今年已过去:'+(getYearofDays() - getYearLastDays())+ '天')
console.log('2022年一共:'+getYearofDays('2022') + '天')
console.log('本月一共:'+getDays() + '天')
console.log('本月一共:'+getDays('2023-02') + '天')

方法

| 名称 | 参数 | 类型 | 默认值 | 说明 | | ---- | ---- | ---- | ----- | ----- | | getYearLastDays | 无 | | | 获取今年剩余天数 | | getYearofDays | year/选填 | number / string | 今年 | 获取指定年份的总天数| | getDays | date/选填 | datestring | 本月 | 获取指定日期的月份天数 |