Mi Lugarcito
Node.js - Twitter Clone Coding // Styling the posts and Outputting posts onto the newsfeed 본문
Express.js
Node.js - Twitter Clone Coding // Styling the posts and Outputting posts onto the newsfeed
selene park 2021. 3. 31. 15:26fontawesome.com/icons?d=gallery&p=2&q=speech%20bubble
Font Awesome
The world’s most popular and easiest to use icon set just got an upgrade. More icons. More styles. More Options.
fontawesome.com
TIP
javascript date to timestamp ago
stackoverflow.com/questions/6108819/javascript-timestamp-to-relative-time
Javascript timestamp to relative time
I'm looking for a nice JS snippet to convert a timestamp (e.g. from Twitter API) to a nice user friendly relative time (e.g. 2 seconds ago, one week ago etc). Anyone care to share some of their
stackoverflow.com
function timeDifference(current, previous) {
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
if (elapsed < msPerMinute) {
return Math.round(elapsed/1000) + ' seconds ago';
}
else if (elapsed < msPerHour) {
return Math.round(elapsed/msPerMinute) + ' minutes ago';
}
else if (elapsed < msPerDay ) {
return Math.round(elapsed/msPerHour ) + ' hours ago';
}
else if (elapsed < msPerMonth) {
return 'approximately ' + Math.round(elapsed/msPerDay) + ' days ago';
}
else if (elapsed < msPerYear) {
return 'approximately ' + Math.round(elapsed/msPerMonth) + ' months ago';
}
else {
return 'approximately ' + Math.round(elapsed/msPerYear ) + ' years ago';
}
}
'Express.js' 카테고리의 다른 글
Node.js - Twitter Clone Coding // Retweeting posts (0) | 2021.03.31 |
---|---|
Node.js - Twitter Clone Coding // The like button (0) | 2021.03.31 |
.append() 와 .appendTo() vs .prepend() 와 .prependTo() 의 차이 (0) | 2021.03.31 |
Ajax 공부하기 (0) | 2021.03.31 |
Node.js - Twitter Clone Coding // RestAPI & Posting (0) | 2021.03.31 |