UNPKG

ascor

Version:

一些常用的简单的js工具

12 lines (11 loc) 439 B
import { dateFormat } from "./dateFormat"; /** * 获取当前时间 例:getCurrentTime(true) * @param {Boolean | String} bool true返回时间戳,false返回Date实例,也可以传入格式化的字符串 如: ‘YYYY-mm-dd HH:MM:SS’ */ export const getCurrentTime = (bool = false) => { if (typeof bool == "string") { return dateFormat(new Date(), bool); } return bool ? new Date().getTime() : new Date(); };