Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DateFunctions(date1, date2)
- {
- this.date1 = new Date(date1);
- this.date2 = new Date(date2);
- this.format = function(date = this.date1){
- return `${date.getDate()}.${date.getMonth()+1}.${date.getFullYear()}`
- }
- this.different_date_in_timeshtamp = function(d1, d2) {
- return Math.abs(+d1 - +d2);
- },
- this.timestamp_to_days = function(bigInt) {
- return Math.round(bigInt/(1000*60*60*24));
- },
- this.different_date_in_days = function(date1, date2) {
- ms = this.different_date_in_timeshtamp(date1, date2);
- return this.timestamp_to_days(ms);
- },
- this.getLastWeekDate = function() {
- date = new Date();
- date.setDate(date.getDate() - 7);
- return this.format(date);
- }
- }
- let date_functions = new DateFunctions('2019-10-11', '2019-11-08');
- console.log(date_functions.format(new Date()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement