PHPackages                             webcito/js-date-extensions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. webcito/js-date-extensions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webcito/js-date-extensions
==========================

description

230

Since Feb 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ThomasDev-de/Js-Date-Extensions)[ Packagist](https://packagist.org/packages/webcito/js-date-extensions)[ RSS](/packages/webcito-js-date-extensions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Js-Date-Extensions
==================

[](#js-date-extensions)

A few useful extensions for the javascript object Date

Table of contents
-----------------

[](#table-of-contents)

- [Js-Date-Extensions](#js-date-extensions)
    - [Table of contents](#table-of-contents)
    - [generell methods](#generell-methods)
        - [setLocale](#setlocale)
        - [getUnits](#getunits)
        - [getDayNames](#getdaynames)
        - [getMonthNames](#getmonthnames)
    - [Method that manipulate the Date object](#method-that-manipulate-the-date-object)
        - [addDays](#adddays)
        - [subDays](#subdays)
        - [addMonths](#addmonths)
        - [subMonths](#submonths)
    - [Methods that return a new instance of the Date object](#methods-that-return-a-new-instance-of-the-date-object)
        - [clone](#clone)
        - [copy](#copy)
        - [getFirstDayOfMonth](#getfirstdayofmonth)
        - [getLastDayOfMonth](#getlastdayofmonth)
        - [getFirstDayOfWeek](#getfirstdayofweek)
        - [getLastDayOfWeek](#getlastdayofweek)
    - [Test methods that return none date object](#test-methods-that-return-none-date-object)
        - [isLeapYear](#isleapyear)
        - [isMonday, isTuesday, isWednesday, isThursday, isFriday, isSaturday, isSunday](#ismonday--istuesday--iswednesday--isthursday--isfriday--issaturday--issunday)
        - [getDaysInMonth](#getdaysinmonth)
        - [getWeek](#getweek)
        - [getCountWeeks](#getcountweeks)
        - [getCountDays](#getcountdays)
        - [fromNow](#fromnow)
        - [getDayName](#getdayname)
        - [getMonthName](#getmonthname)
        - [getMonthCalendar](#getmonthcalendar)

generell methods
----------------

[](#generell-methods)

### setLocale

[](#setlocale)

Set the language

```
// example
Date.setLocale('de');
```

### getUnits

[](#getunits)

Fetches the time units in milliseconds
@return {object}

```
// example
Date.getUnits();
// { year: 31536000000, month: 2628000000, week: 604800000, day: 86400000, hour: 3600000, minute: 60000, second: 1000 }
```

### getDayNames

[](#getdaynames)

@param {boolean} abbreviation Default `false`
@returns {string\[\]}

```
// example
Date.getDayNames(true); // [ "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ]
```

### getMonthNames

[](#getmonthnames)

@param {boolean} abbreviation Default `false`
@returns {string\[\]}

```
// example
Date.getMonthNames(true); // [ "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
```

Method that manipulate the Date object
--------------------------------------

[](#method-that-manipulate-the-date-object)

### addDays

[](#adddays)

Adds a specified number of days to the date
@param {number} days
@return {Date}

```
// example
let date = new Date('2022-11-01');
date.addDays(4); // 2022-11-05
```

### subDays

[](#subdays)

Subtracts a specified number of days from the date
@param {number} days
@returns {Date}

```
// example
let date = new Date('2022-11-01');
date.subDays(4); // 2022-10-28
```

### addMonths

[](#addmonths)

Adds a specified number of months to the date
@param {number} months
@returns {Date}

```
// example
let date = new Date('2022-11-01');
date.addMonths(4); // 2023-03-01
```

### subMonths

[](#submonths)

Subtracts a specified number of months from the date
@param {number} months
@returns {Date}

```
// example
let date = new Date('2022-11-01');
date.subMonths(1); // 2022-10-01
```

Methods that return a new instance of the Date object
-----------------------------------------------------

[](#methods-that-return-a-new-instance-of-the-date-object)

### clone

[](#clone)

@returns {Date}

```
// example
let date = new Date('2022-11-01');
let cloneDate = date.clone(); // 2022-11-01
```

### copy

[](#copy)

Returns a new instance of the Date object (alias of `clone`)
@returns {Date}

```
// example
let date = new Date('2022-11-01');
let copyDate = date.copy(); // 2022-11-01
```

### getFirstDayOfMonth

[](#getfirstdayofmonth)

Determine the first day of the current month
@returns {Date}

```
// example
let date = new Date('2022-11-10');
let firstOfMonth = date.getFirstDayOfMonth(); // 2022-11-01
```

### getLastDayOfMonth

[](#getlastdayofmonth)

Determine the last day of the current month
@returns {Date}

```
// example
let date = new Date('2022-11-10');
let firstOfMonth = date.getLastDayOfMonth(); // 2022-11-30
```

### getFirstDayOfWeek

[](#getfirstdayofweek)

Determine the previous Monday of the current date
@returns {Date}

```
// example
let date = new Date('2022-11-10');
let prevMonday = date.getFirstDayOfWeek(); // 2022-11-07
```

### getLastDayOfWeek

[](#getlastdayofweek)

Determine the Sunday of the current date
@returns {Date}

```
// example
let date = new Date('2022-11-10');
let nextSunday = date.getLastDayOfWeek(); // 2022-11-13
```

Test methods that return none date object
-----------------------------------------

[](#test-methods-that-return-none-date-object)

### isLeapYear

[](#isleapyear)

Checks if the year of the date is a leap year
@returns {boolean}

```
// example
let date = new Date('2024-11-01');
if (date.isLeapYear()) // true
{
    // do something
}
```

### isMonday, isTuesday, isWednesday, isThursday, isFriday, isSaturday, isSunday, isWeekend

[](#ismonday-istuesday-iswednesday-isthursday-isfriday-issaturday-issunday-isweekend)

Checks the date for a weekday
@returns {boolean}

```
// example
let date = new Date('2022-11-01');
date.isMonday(); // false
date.isTuesday(); // true
date.isWednesday(); // false
date.isThursday(); // false
date.isFriday(); // false
date.isSaturday(); // false
date.isSunday(); // false
date.isWeekend(); // false
```

### getDaysInMonth

[](#getdaysinmonth)

Determine the number of days in the current month
@returns {number}

```
// example
let date = new Date('2022-11-01');
date.getDaysInMonth(); // 30
```

### getWeek

[](#getweek)

Determines the calendar week of the date
@returns {number}

```
// example
let date = new Date('2022-11-01');
date.getWeek(); // 44
```

### getCountWeeks

[](#getcountweeks)

Determines the number of weeks between two dates
@param {Date} toDate
@returns {number}

```
// example
let date = new Date('2022-11-01');
let toDate = new Date('2022-11-14');
date.getCountWeeks(toDate); // 2
```

### getCountDays

[](#getcountdays)

Determines the number of days between two dates
@param {Date} toDate
@returns {number}

```
// example
let date = new Date('2022-11-01');
let toDate = new Date('2022-11-14');
date.getCountDays(toDate); // 14
```

### fromNow

[](#fromnow)

```
let date = new Date('2022-11-06 23:54:00');
// Now: 2022-11-07 05:55:00
date.fromNow(); // vor 6 Stunden
```

### getDayName

[](#getdayname)

```
let date = new Date('2022-11-06 23:54:00');
// Now: 2022-11-07 05:55:00
date.getDayName(); // Sonntag
```

### getMonthName

[](#getmonthname)

```
let date = new Date('2022-11-06 23:54:00');
// Now: 2022-11-07 05:55:00
date.getMonthName(); // November
```

### getMonthCalendar

[](#getmonthcalendar)

Returns all data of one month as array
@return {\*\[\]}

```
// example
let date = new Date('2022-11-01');
let result = date.getMonthCalendar();
// output result
[
    {
        "week": 44,
        "days": [
            "2022-10-31T23:00:00.000Z",
            "2022-11-01T23:00:00.000Z",
            "2022-11-02T23:00:00.000Z",
            "2022-11-03T23:00:00.000Z",
            "2022-11-04T23:00:00.000Z",
            "2022-11-05T23:00:00.000Z",
            "2022-11-06T23:00:00.000Z"
        ]
    },
    {
        "week": 45,
        "days": [
            "2022-11-07T23:00:00.000Z",
            "2022-11-08T23:00:00.000Z",
            "2022-11-09T23:00:00.000Z",
            "2022-11-10T23:00:00.000Z",
            "2022-11-11T23:00:00.000Z",
            "2022-11-12T23:00:00.000Z",
            "2022-11-13T23:00:00.000Z"
        ]
    },
    {
        "week": 46,
        "days": [
            "2022-11-14T23:00:00.000Z",
            "2022-11-15T23:00:00.000Z",
            "2022-11-16T23:00:00.000Z",
            "2022-11-17T23:00:00.000Z",
            "2022-11-18T23:00:00.000Z",
            "2022-11-19T23:00:00.000Z",
            "2022-11-20T23:00:00.000Z"
        ]
    },
    {
        "week": 47,
        "days": [
            "2022-11-21T23:00:00.000Z",
            "2022-11-22T23:00:00.000Z",
            "2022-11-23T23:00:00.000Z",
            "2022-11-24T23:00:00.000Z",
            "2022-11-25T23:00:00.000Z",
            "2022-11-26T23:00:00.000Z",
            "2022-11-27T23:00:00.000Z"
        ]
    },
    {
        "week": 48,
        "days": [
            "2022-11-28T23:00:00.000Z",
            "2022-11-29T23:00:00.000Z",
            "2022-11-30T23:00:00.000Z",
            "2022-12-01T23:00:00.000Z",
            "2022-12-02T23:00:00.000Z",
            "2022-12-03T23:00:00.000Z",
            "2022-12-04T23:00:00.000Z"
        ]
    }
]
```

### getWeekCalendar

[](#getweekcalendar)

Returns all data of one week as array
@return {\*\[\]}

```
// example
let date = new Date('2023-02-09');
let result = date.getWeekCalendar();
// output result
[
    "2023-02-06T23:00:00.000Z",
    "2023-02-07T23:00:00.000Z",
    "2023-02-08T23:00:00.000Z",
    "2023-02-09T23:00:00.000Z",
    "2023-02-10T23:00:00.000Z",
    "2023-02-11T23:00:00.000Z",
    "2023-02-12T23:00:00.000Z",
]
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d5f10c16b4b6bd1ac531ffc39c23c569490ec4630829511692c03ec89d36a11?d=identicon)[thomasK81](/maintainers/thomasK81)

---

Top Contributors

[![ThomasDev-de](https://avatars.githubusercontent.com/u/67106837?v=4)](https://github.com/ThomasDev-de "ThomasDev-de (25 commits)")

---

Tags

adddaysaddmonthcalendarclonecopydatefromnowgetdaynamesgetdaysinmonthgetfirstdayofmonthgetfirstdayofweekgetlastdayofmonthgetlastdayofweekgetmonthnamesgetweekisleapyearjavascriptsubdayssubmonth

### Embed Badge

![Health badge](/badges/webcito-js-date-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/webcito-js-date-extensions/health.svg)](https://phpackages.com/packages/webcito-js-date-extensions)
```

###  Alternatives

[recolize/module-recommendation-engine-magento2

The Recolize Recommendation Engine Extension for Magento 2

115.0k](/packages/recolize-module-recommendation-engine-magento2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
