Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

1 day ago javascript

function daysSinceGivenDate(date: Date) {
    const dateInSeconds = Math.floor((new Date().valueOf() - new Date(date).valueOf()) / 1000);
    const oneDayInSeconds = 86400;

    return (dateInSeconds / oneDayInSeconds) | 0; // casted to int
}

console.log(daysSinceGivenDate(new Date())); // 0
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #day #javascript
ADD COMMENT
Topic
Name
3+9 =