跳到主要内容

javascript Date类型扩展日期格式化方法 DateFormat

· 阅读需 1 分钟
一介布衣
全栈开发者
Date.prototype.Format = function (fmt) { //author: meizz 
var o = {
“M+”: this.getMonth() + 1, //月份
“d+”: this.getDate(), //日
“h+”: this.getHours(), //小时
“m+”: this.getMinutes(), //分
“s+”: this.getSeconds(), //秒
“q+”: Math.floor((this.getMonth() + 3) / 3), //季度
“S”: this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + “”).substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp(“(“ + k + “)”).test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((“00″ + o[k]).substr((“” + o[k]).length)));
return fmt;
}

nvm、Node、Yarn 放在一起时,版本边界最好早点说清楚

· 阅读需 3 分钟
一介布衣
全栈开发者

Node.js 项目最容易让人产生一种错觉:只要把 Node 装上、包管理器装上,环境就算齐了。可到了 2020 年左右,团队里同时使用 nvm、Node、Yarn 已经很普遍,这时候真正容易出问题的,不再是某个工具会不会装,而是它们之间的版本边界有没有讲清楚。