1.0.0 • Published 2 years ago
my-custom-node-ygy v1.0.0
###Welcome to use MarkDown
1.安装方式
1.1npm安装
npm i my-tools
3.导入方式
const my = require("my_tools")
3.时间格式化
//格式化时间
function dateFormat(){
var date=new Date()
var year=date.getFullYear()
var month=date.getMonth()
var day=date.getDate()
var hours=date.getHours()
var minutes=date.getMinutes()
var seconds=date.getSeconds()
var str=`${year}年${ month+1}月${day}日${hours}:${ minutes}:${seconds}`
return str
}
module.exports.dateFormat=dateFormat
## 4.转换字符
//转义特殊字符 function zhuanHtml(html){
return html.replace(/<|>|"|&/g,(x)=>{
switch(x){
case "<":
return "<";
case ">":
return ">";
case '"':
return """;
case "&":
return "&";
}
})
}
5.还原字符
//还原特殊字符
function huanHtml(html){
return html.replace(/<|>|"|&/g,(i)={
switch(i){
case "<":
return <;
case ">":
return >;
case """:
return " ;
case "&":
return &;
}
})
}
## 6.开源协议
ISC
1.0.0
2 years ago