Home › JavaScript Tutorial › JS dates
JS dates
Work with date and time.
Create with new Date(). Read parts with getFullYear, getMonth (0-11) and getDay. Format with toLocaleDateString.
Example code
<pre id='o'></pre>
<script>
const d=new Date(2026,10,1);
d.setDate(d.getDate()+30);
o.textContent=[d.getFullYear(),d.getMonth()+1,d.toLocaleDateString('en-IN',{dateStyle:'full'}),d.toISOString()].join('\n');
</script>