developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
옵션확인:
시간을 가지고 요일을 위 함수를 활용해서 구할 수 있다.
client PC 언어 별로 요일을 보여줘야할 때 유용함.
서버에서 SimpleDateFormat 으로 E (요일) 형태로 바꾸면 서버 언어로 바꿔지기 때문에, 날짜 데이터를 받고 화면에서 보여주는거는 js에서 toLocaleDateString에서 바꿔서 출력.
var targetDate = new Date(dataValue);
- dataValue는 string이다.
targetDate.getHours().digit(2) 하면은 2자리 숫자의 시간,
targetDate.getMinutes().digit(2) 하면은 2자리 숫자의 분이 나옴
var options = { weekday: 'short', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit'};
targetDate.toLocaleDateString(undefined, options)
'배운 내용 정리 > JAVASCRIPT' 카테고리의 다른 글
escape(), encodeURI(), encodeURIComponent() (0) | 2020.12.08 |
---|---|
KeyBoardEvent (getModifierState) - 키보드 이벤트(예: Caps Lock 여부) (0) | 2020.12.07 |
arguments (0) | 2020.07.27 |
날짜 변환 함수 (0) | 2020.07.23 |
변수, typeof, 비교연산자, 형변환 (0) | 2020.07.15 |