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

 

Date.prototype.toLocaleDateString()

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

옵션확인:

developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat

 

시간을 가지고 요일을 위 함수를 활용해서 구할 수 있다.

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(undefinedoptions)

 

+ Recent posts