Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
688 B
2
Indexable
Never
    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);

Leave a Comment