Developer community
0 votes
1.3k views
asked by Expert (11.4k points) 16 23 32 | 1.3k views

1 Answer

0 votes
We can pass in numbers to Date class constructors.
the year,
the zero-based month (January is 0, February is 1, and so on)
the day of the month (1 through 31),
the hours (0 through 23),
minutes,
seconds,
milliseconds
The year and month are required.
 
<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">
        var aDate = new Date(2012, 4, 5, 17, 55, 55); 
        document.writeln(aDate);
        //Sat May 05 2012 17:55:55 GMT-0700 (Pacific Daylight Time)
       
    </script>
</head>
<body>
</body>
</html>
 
If the day of the month isn't supplied, it's assumed to be 1. all other omitted arguments are assumed to be 0.
 
<script type="text/javascript">
    var aDate = new Date(2012, 0); 
    document.writeln(aDate);
    //Sun Jan 01 2012 00:00:00 GMT-0800 (Pacific Standard Time)
   
</script>
 
answered by Advisor (8.4k points) 10 15 18

Related questions

0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 14 views
0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 30 views
0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 17 views
0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 26 views
0 votes
1 answer
asked by felin Advisor (8.4k points) 10 15 18 | 913 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,754 questions
4,046 answers
117 comments
10,709 users