JavaScript

Date 객체 생성

윤성탁 2016. 2. 16. 17:44



현재 시간

var currentDate = new Date();


문자열 시간 형태를 Date로 생성 방법

var sampleDate = new Date("2016-02-16T17:43:00");

- 위 형태로 할 경우 IE8이하 브라우저에서 사용할 수 없다.

개선법

var sampleDate = new Date("2016/02/16 17:43:00");

- 크롬/IE 모두 작동됨