-
-
Notifications
You must be signed in to change notification settings - Fork 11
CDN based example
Farhan Reza edited this page Oct 15, 2024
·
5 revisions
Welcome to the diff-ymd-package wiki👋
<!DOCTYPE html>
<html>
<head>
<!-- Download diff-ymd-package from CDN -->
<script src="https://cdn.jsdelivr.net/npm/diff-ymd-package@3.1.4/lib/index.min.js">
</script>
</head>
<body>
<script>
/* Use diff-ymd-package DatesYMD constructor or DatesYMD global object or diff as method of Global Date Object to create an instance*/
const date1 = '2022-01-01';
const date2 = '2023-12-31';
/* Using DatesYMD constructor */
const Formatter = new DatesYMD(date1, date2); // DatesYMD global constructor
/* Using DatesYMD global object `diffDates` method
// Can use `diffDates` method on `DatesYMD` where DatesYMD acts as global Object
const Formatter = DatesYMD.diffDates(date1, date2); // Can use any
*/
/* Using diff as method of Global Date Object
const DateInstance = new Date(date1); // create Global Date instance
const Formatter = DateInstance.diff(date2); //create an instance to `calculates the difference` between `Date instance` and the `date passed to it`
*/
/* Use diff-ymd-package Methods on created instance(Formatter) */
</script>
<!-- Or not mix html with javascript -->
<!-- For this include a script tag for loading script using diff-ymd-package -->
<!-- example: <script src="format-difference.js"></script> -->
</body>
</html>
Use diff-ymd-package Methods on created instance(Formatter)
Use Methods to format difference, See here
Get Built in codes
for using
diff-ymd-package any Method
on created instance(Formatter)