Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
just-now-time
Advanced tools
一些日期处理函数,主要处理为yyyy-mm-dd hh:mm:ss格式
npm i -s just-now-time
import { nowTime,formatTime,timeCn,whatDay,whatDayEn } from "just-now-time"
获取当前时间,接收两个可选参数,用于替换默认间隔符号
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("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
格式化日期为 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("Tue Aug 10 2021 19:23:53 GMT+0800 (GMT+08:00)") // 返回'星期二'
whatDayEn(1628598239000) // 返回'星期二'
获取该日期是星期几(英文),接收一个日期参数,不传参则默认返回今天星期几
whatDayEn() // 返回'Tuesday'
// 搭配大写小转换函数
whatDayEn("2021-08-10").toUpperCase() // TUESDAY
whatDayEn("2021-08-10").toLowerCase() // tuesday
根据年月获取当月天数,和生成的日期数组
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']
}
FAQs
functions for date
The npm package just-now-time receives a total of 0 weekly downloads. As such, just-now-time popularity was classified as not popular.
We found that just-now-time demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.