time.js 763 B

1234567891011121314151617181920212223
  1. export default{
  2. //当前时间,减去信息创建的时间
  3. getTimeLeft(datetimeTo) {
  4. let timeNew = new Date().getTime();
  5. var day=timeNew - datetimeTo;
  6. day = Math.round(day/(24*60*60*1000)) ;// 天
  7. return day;
  8. },
  9. getTime(){
  10. var date = new Date(),
  11. year = date.getFullYear(),
  12. month = date.getMonth() + 1,
  13. day = date.getDate(),
  14. hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
  15. minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
  16. second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  17. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  18. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  19. var timer = year + '-' + month + '-' + day;
  20. return timer;
  21. },
  22. }