Skip to content

Commit

Permalink
FIX : 날짜 형식 수정하기
Browse files Browse the repository at this point in the history
  • Loading branch information
parksewon committed Dec 20, 2021
1 parent 052efef commit 22813c7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions routes/likeRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ const template = require('../template/likes_list');

// prefix: /likes

function dateFormat(date) {
var newdate = new Date(date);
let month = newdate.getMonth() + 1;
let day = newdate.getDate();

month = month >= 10 ? month : '0' + month;
day = day >= 10 ? day : '0' + day;

return newdate.getFullYear() + '.' + month + '.' + day + ' ';
};


router.get('/', function(request, response) {
console.log(request.user);
if(!request.isAuthenticated()){
Expand All @@ -16,17 +28,18 @@ router.get('/', function(request, response) {
FROM post, liked
WHERE post.id = liked.postId and liked.userId=${request.user.id} group by post.id`,
function(err, result) {
console.log(result);

var list ='';
console.log(result[0].createdate)
var date = dateFormat(result[0].createdate);

for (var i = 0;i < result.length; i++) {
list += `
<div class="content">
<a href='/board/view?id=${result[i].id}'>
<div class="subject">
<p>${result[i].title}</p>
<div class="info"><span>${request.user.nickname}</span> | <span>${result[i].createdate}</span></div>
<div class="info"><span>${request.user.nickname}</span> | <span>${date}</span></div>
</div>
</a>
<div class="like">
Expand Down

0 comments on commit 22813c7

Please sign in to comment.