Format a date in Javascript.

1 year ago23k times

code to format a date in JavaScript.


let objectDate = new Date();



let day = objectDate.getDate();
console.log(day); // 12


let currentmo = objectDate.getMonth();
month = currentmo + 1;
console.log(month + 1); // 1


let year = objectDate.getFullYear();
console.log(year); // 2023



// Now you can set it accordingly


// dd/mm/yyyy
console.log(day + '/' + month + '/' + year);


// mm/dd/yyyy
console.log(month + '/' + day + '/' + year);
Other answers


<style>

.bo

height:200px

width:200px

background-color:#131f05

box-shadow:#FB0606 44px 43px 40px 59px

</style>

<div class="box"></div

4403934803897755> };;;;{x4> }2164;;;;{x</div>791

Add Answer

Add a codeAdd Code
Remove adsremove

Latest codes

view all

Latest Snippets

view all