์ƒˆ์†Œ์‹

๐Ÿ“ŒDevelop/โš›๏ธReact

[React] date format / moment / react YYYYMMDD YYYY-MM-DD

  • -

 

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

 

 

 

๋ฐ˜์‘ํ˜•

'๐Ÿ“ŒDevelop > โš›๏ธReact' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[React] axios vs fetch / axios fetch ์ฐจ์ด / axios fetch ์ฐจ์ด์   (0) 2023.07.24
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.