This code works well in most (all?) browsers:
myDate = new Date();
alert(myDate.toString().indexOf("("));
However, when executed within a VB.Net WebBrowser control, it returns -1.
Why is that?
This code works well in most (all?) browsers:
myDate = new Date();
alert(myDate.toString().indexOf("("));
However, when executed within a VB.Net WebBrowser control, it returns -1.
Why is that?
Why is that?
Date
's toString
is not required to output a string that has any (
in it. If the string doesn't have a (
in it, indexOf
will return -1.
From the specification:
- Let O be this Date object.
- If O does not have a [[DateValue]] internal slot, then
- Let tv be NaN.
- Else,
- Let tv be this time value.
- Return ToDateString(tv).
...where ToDateString
says:
- Assert: Type(tv) is Number.
- If tv is NaN, return "Invalid Date".
- Return an implementation-dependent String value that represents tv as a date and time in the current time zone using a convenient, human-readable form.
So that could use no timezone indicator, or a Z to indicate GMT, or a timezone indicator that doesn't use (...)
like GMT+04:00
or -05:00
or similar, etc.