The following code is used to get a date value and then add two hours to it. I would really like to know how to give a condition to add that two hours only between 08:30 in the morning until 18:30 of the evening and skip both the days ( Saturday,Sunday ).
For example: if the given date was in 17:30 of Tuesday so it followed the rule it will be ( 17:30 (of Tuesday ) + 2 = 09:30 ( of Wednesday-the next day) and if the given date was in 17:00 (of Friday) it will be if we skip the week-ends 09:00 ( of Monday-skip week-ends ) etc...
var now = new Date(Date.parse($(".x-form-hidden.x-form-field :eq(0)").val()));
now.setHours(now.getHours() + 2);
var dayVar = "";
if (now.getDate() < 10) {
dayVar = 0 + "" + now.getDate()
} else {
dayVar = now.getDate();
}
var dateString =
now.getFullYear() + "-" +
(now.getMonth() + 1) + "-" +
dayVar + " " +
now.getHours() + ":" + now.getMinutes() + ":0" + now.getSeconds();
$(".x-form-hidden.x-form-field :eq(1)").attr('value', dateString);