In C#, a date can have a min value which is
1/1/0001 12:00:00 AM. This is nice in validation situations.
var minDate = new Date("1/1/0001 12:00:00");
If I convert this to
toISOString(), I'm getting
My API backend in C# is expecting a date value and I don't want to arbitrarily create my own version of
When a string passed into a Date constructor is not in extended ISO format the parsing is completely implementation dependant. If it is in ISO format the parsing is well-defined and it will work exactly the way you want:
var myDate = new Date('0001-01-01T00:00:00Z'); console.log( myDate.getUTCFullYear() );
From MDN Date doc:
year: Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999.
Here, it's talking about the first parameter to
new Date function.
var date = new Date(98, 0); // Thu Jan 01 1998 00:00:00 GMT-0800 (PST)
If you need year 0001 for some reason, use
date.setFullYear(1); console.log(date); // Mon Jan 01 0001 00:00:00 GMT-0800 (PST)
DateTime.MinValue.Date results in an "Invalid Date" � Issue #2582 , Date results in an "Invalid Date" in JS. It seems that Bridge's DateTime.MinValue evaluates to "Tue Apr 20 -271821 01:00:00 GMT+0100 (GMT Standard Time)" on my system, We should be able to get to #2980 soon. Definition and Usage The min property sets or returns the value of the min attribute of a datetime field. The min attribute specifies the minimum value (date and time) for a datetime field. Tip: Use the min attribute together with the max attribute to create a range of legal values.
Tuesday, April 20th, 271,821 BCE
see here for more details: Minimum and maximum date
use the following code var minDate = new Date("1/1/0001 12:00:00"); minDate.toLocaleString();
DateTime.MinValue Field (System), The value of this constant is equivalent to 00:00:00.0000000 UTC, January 1, 0001, in the Gregorian calendar. MinValue defines the date and time that is assigned� The following example instantiates a DateTime object by passing its constructor an Int64 value that represents a number of ticks. Before invoking the constructor, the example ensures that this value is greater than or equal to DateTime.MinValue.Ticks and less than or equal to DateTime.MaxValue.Ticks.