<script> function test(date) { return Math.floor((date - new Date(date.getFullYear(),0,0)) / 1000 / 60 / 60 / 24); } let a = test(new Date()); console.log(a) </script>