-2

can someone help me solve this problem. In my textfield I have a value of January 01,1970 and I want it to change to 1970-01-01(year-month-day). How to do it in javascript?

Greybox
  • 3
  • 1

1 Answers1

1

You can use momentJS

let date = `January 01,1970 `
console.log( moment(date).format('YYYY-MM-DD'))
<script src="https://rawgit.com/moment/moment/2.2.1/min/moment.min.js"></script>
Nasir Kamal
  • 114
  • 1
  • 7
Code Maniac
  • 37,143
  • 5
  • 39
  • 60