0

If I create date like this everything works fine: var someDate = new Date("2013,2,1");.

But I want to add time to this date also. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date <- Here was suggested like this: var someDate = new Date("2013,2,1,1,20"); But it shows Invalid date! How can I create date with thime?

1
  • Use var someDate = new Date(2013,2,1,1,20); instead of var someDate = new Date("2013,2,1") Commented Mar 25, 2014 at 9:56

3 Answers 3

5

Date constructor does not get as an argument string with values. Try with:

var someDate = new Date(2013,2,1,1,20);
1
  • Thanks. Worked like a charm.
    – user2576401
    Commented Mar 25, 2014 at 9:55
1

If you really want a string parameter separated by a comma (,) you can try

new Date("2013,03,15,1:20");
0

Try without "

new Date(2013,2,1,1,20)