[thelist] JS Snippet needed

Mike Foroobar lists at wirelust.com
Tue Aug 5 13:52:24 CDT 2003

function compareDates(date, min, max)
	var now = new Date().getTime();
	var then = new Date(date).getTime();
	var diff = (then - now) / 86400000;
	var valid = true;
	if (diff <= min || diff >= max) {
		return true;
	return valid;

Is that what you're looking for?

You pass it any valid date...

new Date("Month dd, yyyy hh:mm:ss")
new Date("Month dd, yyyy")
new Date(yy,mm,dd,hh,mm,ss)
new Date(yy,mm,dd)
new Date(milliseconds)

And you pass it the least days and the most days and it returns true or 

Christopher Ditty wrote:
> Does anyone have a javascript snippet that checks if a date is within X number of days?  ie....Date must be atleast 2 days out and no farther than 90 days out.  I've done some searching but haven't found anything usable yet.
> Chris
> ------------------------------------------------------------------------------
> 08/05/2003, 10:42:18 AM
> This e-mail and any attachments represent the views and opinions of only the sender and are not necessarily those of Memphis Light, Gas & Water Division, and no such inference should be made.
> ==============================================================================

More information about the thelist mailing list