본문 바로가기

프론트엔드/리액트

리액트로 년, 연, 일 Date출력 toLocaleString 활용

import "./styles.css";

 

export default function App() {

  const date = new Date();

 

  const year = date.toLocaleString("en-US", { year: "numeric" });

  const month = date.toLocaleString("en-US", { month: "long" });

  const day = date.toLocaleString("en-US", { day: "2-digit" });

  return (

    <div className="App">

      <div>년, 월, 일을 여기에 표시합니다.</div>

      <div>

        {year} {month} {day}

      </div>

    </div>

  );

}