Skip to content
Library for extending JavaScript dates
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
lib
test
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.npmignore
.travis.yml
AUTHORS.md
CHANGES.md
CONTRIBUTING.md
Gruntfile.js
LICENSE.md
README.md
bower.json
package-lock.json
package.json

README.md

     888          888                                     888
     888          888                                     888
     888          888                                     888
 .d88888  8888b.  888888 .d88b.          .d88b.  888  888 888888
d88" 888     "88b 888   d8P  Y8b        d8P  Y8b `Y8bd8P' 888
888  888 .d888888 888   88888888 888888 88888888   X88K   888
Y88b 888 888  888 Y88b. Y8b.            Y8b.     .d8""8b. Y88b.
 "Y88888 "Y888888  "Y888 "Y8888          "Y8888  888  888  "Y888

date-ext is a JavaScript library for extending Date objects with useful everyday methods.

Demo Build Status Dev Dependency Status License Release

Install

Install using the package manager for your desired environment(s):

$ npm install --save date-ext
# OR:
$ bower install --save date-ext

If you want to simply download the file to be used in the browser you can find them below:

API

Formatting

Formatting is now extremely simple and uses the same parameters as PHP's date function as well as the escape sequence (backslash).

Date.format(date, formatStr)
new Date().format(formatStr)

Scheduling

Want to schedule a function to be called at a certain time? Well, it couldn't be any easier.

Date.schedule(date, callback[, context])
new Date().schedule(callback[, context])

If the date is now or in the past it will simply be called immediately. Also, if you change your mind you can just prevent it from being called.

Date.unschedule(scheduleId)
new Date().unschedule(scheduleId)

The scheduleId is returned by the call to schedule and will be unique for every call. However, This will be undefined in cases where the function was called immediately.

Miscellaneous

The library also comes packed with a few more simple - yet extremely useful - everyday methods.

new Date().addDays(days)
new Date().addHours(hours)
new Date().addMilliseconds(milliseconds)
new Date().addMinutes(minutes)
new Date().addMonths(months)
new Date().addSeconds(seconds)
new Date().addYears(years)
new Date().clear()
new Date().clearDate()
new Date().clearTime()
new Date().getDayOfYear()
new Date().getDaysInMonth()
new Date().getTimezone()
new Date().getWeekOfYear()
new Date().getYearOfWeek()
new Date().isDaylightSavingTime()
new Date().isLeapYear()

Bugs

If you have any problems with date-ext or would like to see changes currently in development you can do so here.

Contributors

If you want to contribute, you're a legend! Information on how you can do so can be found in CONTRIBUTING.md. We want your suggestions and pull requests!

A list of date-ext contributors can be found in AUTHORS.md.

License

Copyright © 2017 Alasdair Mercer

See LICENSE.md for more information on our MIT license.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.