2

I already did some reasearch and found out that you need to format a date String because the IE can't handle some formats. But the problem is that I don't even get a current date string to format.

Date.now() or Date.time()

I also tried this if-statement:

if (!Date.now) {
    Date.now = function() { return new Date().getTime(); }
}

But I always retrieve "nan", even in IE11.

In Chrome and Firefox it works perfectly. So how do I get the currentTime in IE?

user2718671
  • 2,866
  • 9
  • 49
  • 86
  • 2
    var date = new Date(); – user3227295 May 19 '15 at 07:19
  • 1
    uhm... in javascript you just do new Date()? and then you have a date object with the current time. No difference between any browsers. I think you are overcomplicating things with your checks. https://msdn.microsoft.com/library/ff743760%28v=vs.94%29.aspx – Tschallacka May 19 '15 at 07:20
  • [Get Current Date In JavaScript](http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript) – Shubh May 19 '15 at 07:20

3 Answers3

2

This is an easy work-around that should do for your problem: Put this line at the top of your file
Date.now = Date.now || function() { return +new Date; };
If you need any more date formating features I can only encourage you to take a look at http://momentjs.com/

Fabio
  • 103
  • 10
2

You can handle like this -

Date.prototype.now = function() { return typeof(Date.now) == 'function' ? Date.now() : new Date().getTime(); }; 

and use as,

var dateNow = new Date().now();
iTechOwl
  • 150
  • 11
0

Try this

datetField.sendKeys((d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear());
RRR
  • 75
  • 2
  • 11