Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript에서 날짜 구문 분석은 무엇을 사용합니까?

<시간/>

파싱 날짜는 밀리초 단위로 시간을 알려줍니다. Date.parse() 파싱 하는 데 사용됩니다. 날짜. 이 메서드는 실제로 제공된 날짜와 1970년 1월 1일 사이의 밀리초 수를 반환합니다. 개발자는 1970년 1월 1일부터 제공된 날짜까지의 시간을 밀리초 단위로 가져오도록 프로그래밍했습니다.

예시-1

다음 예에서는 Date.parse()를 사용하여 밀리초 수는 2019년 7월 14일과 1970년 1월 1일 사이에 계산되었습니다.

<html>
<body>
   <p>Date.parse() returns the number of milliseconds between
      july 14, 2019 and January 1, 1970 </p>
   <script>
      var time = Date.parse("july 14, 2019");
      document.write(time);
   </script>
</body>
</html>

출력

1563042600000

예시-2

다음 예에서는 Date.parse()를 사용하여 1999년 6월 14일과 1970년 1월 1일 사이에 밀리초 수를 계산했습니다.

<html>
<body>
   <p>Date.parse() returns the number of milliseconds between
   the june 14, 1999 and January 1, 1970: </p>
   <script>
      var time = Date.parse("june 14, 1999");
      document.write(time);
   </script>
</body>
</html>

출력

929298600000