0
 var time_in = data[i].timeIn;//data[i].timeIn= 2015-04-18 1:00:30
 time_in = new Date(time_in);

In Firefox, the result of time_in in console is → Date {Invalid Date}.

In Chrome, the result of time_in in console is → Sat Apr 18 2015 01:00:30 GMT+0630 (Myanmar Standard Time)

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
  • what does data contain? – Danyal Sandeelo May 18 '15 at 06:42
  • @DanyalSandeelo See the comment in his code example. Use `new Date("2015-04-18 1:00:30")` to test. – Mörre May 18 '15 at 06:44
  • 2
    Have a look at these posts, [StackOverflow explanation][1] [Another explanation in stackoverflow][2] [1]: http://stackoverflow.com/questions/3257460/new-date-is-working-in-chrome-but-not-firefox [2]: http://stackoverflow.com/questions/12822225/javascript-date-function-returns-date-invalid-date-in-firefox-browser – Janaki Sathiyamurthy May 18 '15 at 06:45
  • 1
    If you want all browsers to parse the date correctly use a ISO 8601 formatted date or use a date parser like [moment js](http://momentjs.com/docs/#/parsing/string-format/) – Arun P Johny May 18 '15 at 06:47

2 Answers2

3

The date you have given as a parameter is invalid, though browsers may try to interpret it either way.

You should use either RFC2822, or ISO 8601 format instead, it works better in cross-browser situations. For example, this would be a date in ISO 8601 format:

2015-04-18T01:00:30+0630

By the way, the ISO 8601 format must be valid in an ECMAScript 5 complaint environment.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
-2

Please Try this

new Date();
new Date(value);
new Date(dateString);
new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);

You can learn about this function from following link

LINK

Vikram Anand Bhushan
  • 4,836
  • 15
  • 68
  • 130