This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
date-ext with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
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 objects with useful
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:
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)
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)
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.
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()
If you have any problems with date-ext or would like to see changes currently in development you can do so here.
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.
Copyright © 2017 Alasdair Mercer
See LICENSE.md for more information on our MIT license.