Untitled

 avatar
unknown
plain_text
10 months ago
688 B
5
Indexable
    const now = new Date();

    // Set date to the first day of the current month
    const firstDayOfCurrentMonth = new Date(now.getFullYear(), now.getMonth(), 1);

    // Move to the last day of the previous month
    const lastDayOfLastMonth = new Date(firstDayOfCurrentMonth);
    lastDayOfLastMonth.setDate(lastDayOfLastMonth.getDate() - 1);

    // Get the first day of the last month
    const firstDayOfLastMonth = new Date(lastDayOfLastMonth.getFullYear(), lastDayOfLastMonth.getMonth(), 1);

    // Set startDate and endDate
    const startDate = firstDayOfLastMonth;
    const endDate = new Date(lastDayOfLastMonth);
    endDate.setHours(23, 59, 59, 999);

Editor is loading...
Leave a Comment