Time in Javascript

Check Time, Lead time, Crease Time, Decrease Time

function checkTime(value) {
    let d = new Date(0).setHours(value.substr(0, 2), value.substr(3, 2));
    let e = new Date(d);
    return e;
}

function checkLead(lead) {
    let d = new Date(0);
    console.log(d);
    d.setMinutes(d.getMinutes() + lead);
    console.log(d)
}

function increaseTime(value, lead) {
    let d = new Date(0).setHours(value.substr(0, 2), value.substr(3, 2));
    let e = new Date(d);
    let f = e.setMinutes(e.getMinutes() + lead);
    let g = new Date(f)
    return g.toString().substr(16, 5);
}

function decreaseTime(value, lead) {
    let d = new Date(0).setHours(value.substr(0, 2), value.substr(3, 2));
    let e = new Date(d);
    let f = e.setMinutes(e.getMinutes() - lead);
    let g = new Date(f)
    return g.toString().substr(16, 5);
}

Leave a Reply

Your email address will not be published. Required fields are marked *