How to calculate date in Javascript

linkaiyi
Follow

calculate date in Javascript

var today = new Date();
        var seconds = today.getSeconds();
        var minutes = today.getMinutes();
        var hour = today.getHours();
        var dd = today.getDate(); // String(today.getDate()).padStart(2, '0');
        var mm = today.getMonth() + 1; //String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
        var yyyy = today.getFullYear();
        window.current_month = yyyy + '-' + mm;
Object has 0 attachments

Was this article helpful?

This article is viewed 12 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support