[FX.php List] [OFF] Javascript question--comparing dates

Ness, David dness at bondedbuilders.com
Wed Dec 3 12:53:07 MST 2014


Bob,

Since getToday() isn't a JavaScript function, I assume it's a custom function?


David Ness
FileMaker & Web Applications Developer

Bonded Builders Warranty Group
St. Petersburg, Florida USA
800-749-0381 x4923

-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Bob Patin
Sent: Wednesday, December 03, 2014 2:18 PM
To: FX.php Discussion List
Subject: [FX.php List] [OFF] Javascript question--comparing dates

OK, list, this should be really easy, but I can’t get the proper results:

I have this code:

var date1 = getToday();
var date2 = new Date("12/01/2014");
var res = compareDates(date1,date2);
alert(res);

Here’s the function:

// compare any 2 dates
	// 0 -- date1 < date2
	// 1 -- dates are equal
	// 2 -- date1 > date2

function compareDates(date1, date2){
	if (+date1 < +date2){
		return 0;
	}else if (+date1 == +date2){
		return 1;
	}else if (+date1 > +date2){
		return 2;
	}else{
		return "UNSOLVED";
	}
} 

If you try this, you’ll get UNSOLVED rather than the right answer, which should be 2, because date1 > date2 in my example.

This is so easy to do in PHP, but for some reason, despite lots of Googling, I haven’t gotten anything that works.

Thanks for any enlightenment,

Bob Patin
Longterm Solutions
bob at longtermsolutions.com
615-333-6858
FileMaker 9, 10, 11, 12 & 13 Certified Developer http://www.longtermsolutions.com
-
iChat: bobpatin at me.com
Twitter: bobpatin
—
FileMaker Consulting
FileMaker Hosting for all versions of FileMaker PHP • Full email services • Free DNS hosting • Colocation • Consulting

 
 _______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list


More information about the FX.php_List mailing list