1

Is there any way to get the same value of date time in javascript that c# DateTime.MaxValue returns?

Frank
  • 431
  • 1
  • 5
  • 25
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105

2 Answers2

4

The above edge case as mentioned by James Thorpe can be avoided by using:

    public dateTimeMax = new Date(9999, 11, 31, 23, 59, 59, 999);

This is because the month is zero-indexed, and the highest value it can take for milliseconds is 999.

markeh21
  • 189
  • 12
2

Well, yes. The max date in .NET is 23:59:59.9999999 UTC, December 31, 9999. So this would be the equivalent Javascript:

var d = new Date(9999, 12, 31, 23, 59, 59, 9999999);

There is no Date.MaxValue in Javascript, so you have to make it your own.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325