Getting JavaScript equivalent of DateTime.MinValue

In C#, a date can have a min value which is 1/1/0001 12:00:00 AM. This is nice in validation situations.

I tried producing this value in JavaScript but it's not working:

var minDate = new Date("1/1/0001 12:00:00");

If I convert this to toISOString(), I'm getting "2001-01-01T18:00:00.000Z".

My API backend in C# is expecting a date value and I don't want to arbitrarily create my own version of DateTime.MinValue in JavaScript. Is there a way for me to produce this value in JavaScript?


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() );

Javascript Date & Time Min & max values Example, Javascript Date and time demo with restricted selection. Great for age verification and DOB/birthday picker. Plain JS api for usage everywhere. Getting JavaScript equivalent of DateTime.MinValue. Ask Question Asked 1 year, 8 months ago. Active 9 months ago. Viewed 6k times 2. 1. In C#, a date


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 setFullYear(..).

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.


'1/1/0001' is not the minimum date in JavaScript, -8640000000000000 is the minimum timestamp available in JavaScript, so the minimum date is

new Date(-8640000000000000)

which is Tuesday, April 20th, 271,821 BCE

see here for more details: Minimum and maximum date

HTML DOM Input Datetime min Property, Example. Get the minimum date and time allowed for a datetime field: The min attribute specifies the minimum value (date and time) for a datetime field. Given an array of JavaScript date. The task is to get the minimum and maximum date of the array using JavaScript. Approach 1: Get the JavaScript dates in an array. Use Math.max.apply() and Math.min.apply() function to get the maximum and minimum dates respectively.


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.


set min and maximum date (JavaScript), an experts help me with this code set to maximum only, how can i add a minimum date in a field? thanks // Custom validate script if (event.value) { // Maximum� Calling DateTime.MinValue.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, whereas I would've expected this to replicate .NET's MinValue of "0001-01-01 00:00:00" instead.


How to get the smallest (earliest) possible Date value, I question the validity of what you're doing, since I've never seen this to be necessary, but since you asked, from the docs: The earliest valid date is� I was wondering which is the minimum and the maximum date allowed for a Javascript Date object. I found that the minimum date is something like 200000 B.C., but I couldn't get any reference about it. I found that the minimum date is something like 200000 B.C., but I couldn't get any reference about it.


Date, JavaScript Date objects represent a single moment in time in a standard Date object (equivalent to �8,640,000,000,000,000 milliseconds). In order to create and get dates between the years 0 and 99 the Date.prototype. JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC. Description The ECMAScript epoch and timestamps. A JavaScript date is fundamentally specified as the number of milliseconds that have elapsed since midnight on January 1