const currentDate = new Date()
console.log(currentDate)
//Output: 2022-01-29T10:03:47.564Z
์ด์ ๊ป ๋ด์๋ Javascript์ ํ์์ด๋ค!
๐Monent
๐How to Install
๐npm ๋๋ yarn ์ ์ด์ฉํ ์ค์น ๋ช
๋ น์ด
$ npm install moment --save
// ๋๋
$ yarn add moment
๐ Code Sample ์ฝ๋ ์์
import "./index.css"
import Moment from 'moment';
import "moment/locale/ko"; // Locale Setting
function App() {
const formatDate = Moment().format('YYYY-MM-DD')
/*
* Year : YYYY
* Month : MM
* Day : DD
* Hour : HH
* Min : mm
* Sec : ss
*/
return (
<div className='container'>
<h1>{formatDate}</h1>
</div>
);
}
export default App;
๐์คํํด๋ณด์!
// format์ ๋ง๊ฒ ์ถ๋ ฅ๋๋ค.
const nowTime = moment().format('YYYYMMDD HH:mm:ss');
console.log(nowTime);
// ์ถ๋ ฅ ๊ฒฐ๊ณผ: 20210818 09:41:32