| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /**
- * 日期时间工具类,后期慢慢收集累积
- * createDate 2021-11-02
- */
- let dateTime = {}
- /**
- * 获取当前时间
- * @return {String} 2021-11-02 19:53:22
- */
- dateTime.now=()=>{
- var mydate = new Date();
- var str = "" + mydate.getFullYear() + "-";
- if(mydate.getMonth()<10){
- str +="0"+ (mydate.getMonth() + 1) + "-";
- }else{
- str += (mydate.getMonth() + 1) + "-";
- }
- if(mydate.getDate()<10){
- str += "0"+mydate.getDate() + " ";
- }else{
- str += mydate.getDate() + " ";
- }
- if(mydate.getHours()<10){
- str += "0"+mydate.getHours() + ":";
- }else{
- str += mydate.getHours() + ":";
- }
- if(mydate.getMinutes()<10){
- str += "0"+mydate.getMinutes() + ":";
- }else{
- str += mydate.getMinutes() + ":";
- }
- if(mydate.getSeconds()<10){
- str += "0"+mydate.getSeconds();
- }else{
- str += mydate.getSeconds();
- }
- return str;
- }
- export default dateTime
|