Jump to content

[SOLVED] Help needed with Javascript


jdadwilson

Recommended Posts

First let me say I am a complete newbie to javascript.

 

I found the following script recently. Its purpose is to identify if a date is a holiday. Looks very good. Problem is this I have no clue as to the required format of the input variable.

 

Any help is greatly appreciated.

 

TIA... here is a snippet of the function.

 

function check_holiday (dt_date) {

 

// check simple dates (month/date - no leading zeroes)

var n_date = dt_date.getDate(),

n_month = dt_date.getMonth() + 1;

var s_date1 = n_month + '/' + n_date;

 

if ( s_date1 == '1/1' // New Year's Day

|| s_date1 == '6/14' // Flag Day

|| s_date1 == '7/4' // Independence Day

|| s_date1 == '11/11' // Veterans Day

|| s_date1 == '12/25' // Christmas Day

) return true;

 

return false;

}

Link to comment
https://forums.phpfreaks.com/topic/61154-solved-help-needed-with-javascript/
Share on other sites

looks like its being passed a date object, consider the following...

 

// checks to see if todays date is a holiday
var dt_date= new Date();
if(check_holiday (dt_date)) {
    alert("date OK");
}

// check another date
var dt_date= new Date("October 12, 1988");
if(check_holiday (dt_date)) {
    alert("date OK");
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.