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

just-now-time

v1.0.26

Published

functions for date

Downloads

6

Readme

一些日期处理函数,主要处理为yyyy-mm-dd hh:mm:ss格式

🚀install

npm i -s just-now-time

🚀import

import { nowTime,formatTime,timeCn,whatDay,whatDayEn } from "just-now-time"

✨nowTime

获取当前时间,接收两个可选参数,用于替换默认间隔符号

nowTime() 
nowTime(".", "/") 

默认返回数据格式如下

{
  date: "2021-12-22"
  dateObj: {year: '2021', month: '12', day: '22'}
  full: "2021-12-22 11:12:56"
  time: "11:12:56"
  timeObj: {hour: '11', minute: '12', second: '56'}
}

✨formatTime

格式化日期。接收三个参数,一参数必传,为日期,二三参数可选,替换默认间隔符号,不传参则默认返回当天日期格式化

formatTime() // 默认返回当天日期格式化
formatTime("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)") 
formatTime("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)",".", "/") // 替换默认间隔符号

返回数据格式同nowTime

✨timeCn

格式化日期为 yyyy 年 m 月 d 日 h 时 m 分 s 秒形式,接受一个必传参数日期,不传参则默认返回当天日期格式化

timeCn() // 默认返回当天日期格式化
timeCn("Tue Aug 10 2021 20:23:59 GMT+0800 (GMT+08:00)") 

返回数据格式如下

{
 date: "2021年12月22日"
 dateObj: {year: '2021年', month: '12月', day: '22日'}
 full: "2021年12月22日 12时00分37秒"
 time: "12时00分37秒"
 timeObj: {hour: '12时', minute: '00分', second: '37秒'}
}

✨whatDay

获取该日期是星期几(中文),接收一个日期参数,不传参则默认返回今天星期几

whatDay() // 返回'星期二'
whatDay("Tue Aug 10 2021 19:23:53 GMT+0800 (GMT+08:00)") // 返回'星期二'
whatDayEn(1628598239000) // 返回'星期二'

✨whatDayEn

获取该日期是星期几(英文),接收一个日期参数,不传参则默认返回今天星期几

whatDayEn() // 返回'Tuesday'
// 搭配大写小转换函数
whatDayEn("2021-08-10").toUpperCase() // TUESDAY
whatDayEn("2021-08-10").toLowerCase() // tuesday

✨getDays

根据年月获取当月天数,和生成的日期数组

getDays("2021", "12")

返回数据格式如下

{
  day: (31) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,   29, 30, 31]
  monthDay: (31) ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06', '12-07', '12-08', '12-09', '12-10', '12-     11', '12-12', '12-13', '12-14', '12-15', '12-16', '12-17', '12-18', '12-19', '12-20', '12-21', '12-22', '12-23',  '12-24', '12-25', '12-26', '12-27', '12-28', '12-29', '12-30', '12-31']
 number: 31
 yearMonthDay: (31) ['2021-12-01', '2021-12-02', '2021-12-03', '2021-12-04', '2021-12-05', '2021-12-06', '2021-12-   07', '2021-12-08', '2021-12-09', '2021-12-10', '2021-12-11', '2021-12-12', '2021-12-13', '2021-12-14', '2021-12-   15', '2021-12-16', '2021-12-17', '2021-12-18', '2021-12-19', '2021-12-20', '2021-12-21', '2021-12-22', '2021-12-   23', '2021-12-24', '2021-12-25', '2021-12-26', '2021-12-27', '2021-12-28', '2021-12-29', '2021-12-30', '2021-12-   31']
}