ascor
Version:
一些常用的简单的js工具
13 lines (12 loc) • 478 B
JavaScript
import { dateFormat } from "./dateFormat";
/**
* 获取当前时间 例:getCurrentTime(true)
* @param {Boolean | String} bool true返回时间戳,false返回Date实例,也可以传入格式化的字符串 如: ‘YYYY-mm-dd HH:MM:SS’
*/
export var getCurrentTime = function (bool) {
if (bool === void 0) { bool = false; }
if (typeof bool == "string") {
return dateFormat(new Date(), bool);
}
return bool ? new Date().getTime() : new Date();
};