Fm-Group

Diễn đàn miễn phí : Chia sẻ và giúp đỡ


Title of the topic

AdminAdmin Tổng số bài gửi : 25
First topic message reminder :

Title of the topicTitle of the topicTitle of the topicTitle of the topicTitle of the topicTitle of the topicTitle of the topicTitle of the topicTitle of the topic

#1Fri Mar 30, 2018 11:04 pm

AdminAdmin Tổng số bài gửi : 25
Nô nô nô

#6Sat Mar 31, 2018 6:23 pm
AdminAdmin Tổng số bài gửi : 25
Code:
function timeSince(date) {

  var seconds = Math.floor((new Date() - date) / 1000);

  var interval = Math.floor(seconds / 31536000);

  if (interval > 1) {
    return interval + " years";
  }
  interval = Math.floor(seconds / 2592000);
  if (interval > 1) {
    return interval + " months";
  }
  interval = Math.floor(seconds / 86400);
  if (interval > 1) {
    return interval + " days";
  }
  interval = Math.floor(seconds / 3600);
  if (interval > 1) {
    return interval + " hours";
  }
  interval = Math.floor(seconds / 60);
  if (interval > 1) {
    return interval + " minutes";
  }
  return Math.floor(seconds) + " seconds";
}
var aDay = 24*60*60*1000
console.log(timeSince(new Date(Date.now()-aDay)));
console.log(timeSince(new Date(Date.now()-aDay*2)));

#7Sun Apr 01, 2018 1:56 pm
Sponsored content

#8