728x90

const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZoneName: 'long' };

 

이게 중요한거같아

const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

console.log(event.toLocaleDateString('de-DE', options));
// expected output: Donnerstag, 20. Dezember 2012

console.log(event.toLocaleDateString('ar-EG', options));
// expected output: الخميس، ٢٠ ديسمبر، ٢٠١٢

console.log(event.toLocaleDateString(undefined, options));
// expected output: Thursday, December 20, 2012 (varies according to default locale)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

 

Date.prototype.toLocaleDateString() - JavaScript | MDN

The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of this date. The new locales and options arguments let applications specify the language whose formatting conventions should be used and allow to

developer.mozilla.org

 

https://ichi.pro/ko/tolocaledatestring-eul-sayonghayeo-javascript-naljja-hyeongsig-jijeong-45462506610720

 

toLocaleDateString을 사용하여 JavaScript 날짜 형식 지정

도우미 기능이 없으면 날짜 형식을 지정하는 것이 어렵습니다. 로케일에 민감한 방식으로 날짜 형식을 지정해야하는 것은 훨씬 더 고통 스럽습니다.

ichi.pro

 

 

 

참고로 투두리스트 만들 때 시간 적용한 코드는 이와 같음

new Date(); 생성자로 불러와서 쓰는듯

728x90

'웹 공부' 카테고리의 다른 글

객체지향 절차지향  (0) 2021.11.29
비주얼스튜디오 폴더 사용, 깃, 리액트 깔기 팁  (0) 2021.11.03
배열과 객체 차이  (0) 2021.10.27
디버깅/npm/path  (0) 2021.09.24
java 반복문 for문으로 별찍기/ while문  (0) 2021.08.18

+ Recent posts