Skip to content

Commit

Permalink
Merge pull request #146 from Kusitms-29th-ASAP/fix/#140
Browse files Browse the repository at this point in the history
[Fix] 로컬 시간과 UTC 시간 차로 인한 날짜 오류 수정
  • Loading branch information
yyypearl authored Sep 4, 2024
2 parents 6575f81 + ac0ed55 commit b98b073
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/home/Todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ const Todo = () => {

/* 날짜를 yyyy-mm-dd 형식으로 변환하는 함수 */
const formatDate = (date: Date) => {
return date.toISOString().split("T")[0];
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
};

useEffect(() => {
Expand All @@ -54,6 +57,8 @@ const Todo = () => {

useEffect(() => {
let formattedDate = formatDate(currentDate);
console.log("new Date()", new Date());
console.log("formattedDate", formattedDate);
Axios.get(`/api/v1/todos?date=${formattedDate}`)
.then((response) => {
const todoData: Todo[] = response.data.todoList;
Expand Down

0 comments on commit b98b073

Please sign in to comment.