utils.js 429 B

123456789101112131415
  1. export default {
  2. getNow(fmt){
  3. let now=new Date();
  4. let y=now.getFullYear(),m=now.getMonth()+1,d=now.getDate(),h=now.getHours(),mi=now.getMinutes(),s=now.getSeconds();
  5. m=m>9?m.toString():('0'+m);
  6. d=d>9?d.toString():('0'+d);
  7. h=h>9?h.toString():('0'+h);
  8. mi=mi>9?mi.toString():('0'+mi);
  9. s=s>9?s.toString():('0'+s);
  10. if(fmt=='mm月dd日'){
  11. return `${m}月${d}日`;
  12. }
  13. return `${y}-${m}-${d} ${h}:${mi}:${s}`;
  14. }
  15. }