Is there any way to get the same value of date time in javascript that c# DateTime.MaxValue returns?
Asked
Active
Viewed 3,000 times
1
Frank
- 432
- 1
- 5
- 22
Pawan Nogariya
- 7,698
- 12
- 47
- 92
-
1This can possibly help you: http://stackoverflow.com/questions/11526504/minimum-and-maximum-date – henrikmerlander Apr 29 '16 at 09:28
2 Answers
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
- 148,824
- 21
- 237
- 306
2
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
- 169
- 12