.net, there are the static properties
DateTime.MinDate, and DateTime.MaxDate that conveniently return the minimum and maximum valid dates for a DateTime object.
I’m dabbling in web programming right now, using
min/max date values in that programming environment? For example, the max value of a date object in mysql is 9999-12-31, but the php function strtotime() doesn’t like that value.
I’ll just answer the PHP portion of the question. According to the PHP date() documentation:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer)
PHP uses 32 bit integer values to represent date/time — that means you can use the PHP_INT_MAX constant to derive the integer values associated with the min/max dates:
echo date('m/d/Y G:i:s', PHP_INT_MAX + 1); // minimum valid date echo date('m/d/Y G:i:s', PHP_INT_MAX); // maximum valid date
Not sure why that’s off by 2 seconds on the min date they quoted, but you get the general idea.
The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day holds 86,400,000 milliseconds. The Date object range is -100,000,000 days to 100,000,000 days relative to 01 January, 1970 UTC.
var min_date = new Date(-100000000*86400000); var max_date = new Date( 100000000*86400000);
For the ‘not set yet’ logical value, maybe a null value is better.