Date input in an HTML Form gives arbitrary date

I have a form in a website that goes to a node.js backend, and in the form there’s two date selectors. When trying to pick a date I can’t get any results other than two arbitrary dates, which are Feb 1st 2024 and Oct 1st 2024.

I am not sure if I am missing something obvious or what is causing this bug.

What should I be doing different?/How can I get the date inputs to give the correct date?

HTML:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
<div class="container parse">
<form action="/parse" method="post">
<select name="location" id="location" required>
<option value="none" selected disabled hidden>Institución</option>
<option value="1"> Arcoiris EP </option>
<option value="1"> Albores ES </option>
</select>
<input type="date" name="startDate" id="startDate" required>
<input type="date" name="endDate" id="endDate" required>
<select name="employee" id="employee">
<option value="none" selected disabled hidden>Empleado</option>
<option value="none" >Todos</option>
<!--list of employees from js array-->
</select>
<button class="btn"
<!--htmx post req-->
> Buscar </button>
</form>
</div>
</code>
<code> <div class="container parse"> <form action="/parse" method="post"> <select name="location" id="location" required> <option value="none" selected disabled hidden>Institución</option> <option value="1"> Arcoiris EP </option> <option value="1"> Albores ES </option> </select> <input type="date" name="startDate" id="startDate" required> <input type="date" name="endDate" id="endDate" required> <select name="employee" id="employee"> <option value="none" selected disabled hidden>Empleado</option> <option value="none" >Todos</option> <!--list of employees from js array--> </select> <button class="btn" <!--htmx post req--> > Buscar </button> </form> </div> </code>

<div class="container parse">
    <form action="/parse" method="post">
        <select name="location" id="location" required>
            <option value="none" selected disabled hidden>Institución</option>
            <option value="1"> Arcoiris EP </option>
            <option value="1"> Albores ES </option>
        </select>
        <input type="date" name="startDate" id="startDate" required>
        <input type="date" name="endDate" id="endDate" required>
        <select name="employee" id="employee">
            <option value="none" selected disabled hidden>Empleado</option>
            <option value="none" >Todos</option>
            <!--list of employees from js array-->
          </select>
        <button class="btn"
           <!--htmx post req-->
        > Buscar </button>
    </form>
</div>

and the post request looks like:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>app.post('/parse', (req, res) => {
params = {
location: req.body.location,
employee: req.body.employee,
startDate: turnToDate(req.body.startDate),
endDate: turnToDate(req.body.endDate),
};
console.log(`The parameters to search for are:
start date: ${params.startDate} end date: ${params.endDate}
for employee: ${params.employee}`) //***
const displayTable = mdb.parseMainTable(parseTable,
params.startDate, params.endDate, params.employee);
const stringifiedHTML = createHTML(displayTable);
res.send(stringifiedHTML);
//parseMainTable function from mdb module:
const parseMainTable = (parseTable, startDate, endDate, employee) => {
let employeeFilteredTable = [];
let displayTable = [];
if (employee != 'none') {
employee = Number(employee);
employeeFilteredTable = parseTable.filter((el) => (el.id == employee));
} else {
employeeFilteredTable = parseTable
};
displayTable = employeeFilteredTable.filter((el) => (
el.timestamp >= startDate
&&
el.timestamp <= endDate
));
return displayTable;
};
</code>
<code>app.post('/parse', (req, res) => { params = { location: req.body.location, employee: req.body.employee, startDate: turnToDate(req.body.startDate), endDate: turnToDate(req.body.endDate), }; console.log(`The parameters to search for are: start date: ${params.startDate} end date: ${params.endDate} for employee: ${params.employee}`) //*** const displayTable = mdb.parseMainTable(parseTable, params.startDate, params.endDate, params.employee); const stringifiedHTML = createHTML(displayTable); res.send(stringifiedHTML); //parseMainTable function from mdb module: const parseMainTable = (parseTable, startDate, endDate, employee) => { let employeeFilteredTable = []; let displayTable = []; if (employee != 'none') { employee = Number(employee); employeeFilteredTable = parseTable.filter((el) => (el.id == employee)); } else { employeeFilteredTable = parseTable }; displayTable = employeeFilteredTable.filter((el) => ( el.timestamp >= startDate && el.timestamp <= endDate )); return displayTable; }; </code>
app.post('/parse', (req, res) => {

params = {
    location: req.body.location,
    employee: req.body.employee,
    startDate: turnToDate(req.body.startDate),
    endDate: turnToDate(req.body.endDate),
};

console.log(`The parameters to search for are:
            start date: ${params.startDate} end date: ${params.endDate}
            for employee: ${params.employee}`) //***
const displayTable = mdb.parseMainTable(parseTable,
    params.startDate, params.endDate, params.employee);
const stringifiedHTML = createHTML(displayTable);
res.send(stringifiedHTML); 


//parseMainTable function from mdb module:

const parseMainTable = (parseTable, startDate, endDate, employee) => {
    let employeeFilteredTable = [];
    let displayTable = [];

    if (employee != 'none') {
        employee = Number(employee);
        employeeFilteredTable = parseTable.filter((el) => (el.id == employee));
    } else {
        employeeFilteredTable = parseTable
    };

    displayTable = employeeFilteredTable.filter((el) => (
        el.timestamp >= startDate 
        &&
        el.timestamp <= endDate
    ));

    return displayTable;
};

*** always logs “The parameters to search for are:
start date: Thu Feb 01 2024 00:00:00 GMT-0300 (Brasilia Standard Time) end date: Tue Oct 01 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
for employee: none” or
The parameters to search for are:
start date: Tue Oct 01 2024 00:00:00 GMT-0300 (Brasilia Standard Time) end date: Tue Oct 01 2024 00:00:00 GMT-0300 (Brasilia Standard Time)
for employee: none

The list therefore ends up containing items in this arbitrary date range and nowhere else.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật