0

I want to display today's date into a bootstrap form while keeping the input type set to 'date', the same for another input that is input type is 'time'. I'm seeing solutions that involve the input type to be 'text'. Is there anyway to display today's date either via Javascript or PHP?

TheRCMKid
  • 13
  • 3

1 Answers1

0

https://jsfiddle.net/j2177yuw/1/. Use https://momentjs.com/ to get today date

document.getElementById('date').value = moment().format('YYYY-MM-DD')

Use datepicker instead since input type date only works on chrome.

asnawi
  • 99
  • 3
  • Asnawi: don't copy paste the other answer. You have copied from this answer, which is very similar like your: https://stackoverflow.com/questions/12409299/how-to-get-current-formatted-date-dd-mm-yyyy-in-javascript-and-append-it-to-an-i – Suresh Sapkota Aug 23 '17 at 01:00
  • i copied from here only to get the current date. https://stackoverflow.com/questions/1531093/how-do-i-get-the-current-date-in-javascript. didn't know there are similar answer as your comment above – asnawi Aug 23 '17 at 01:17
  • This line proved that it is copied: var mm = today.getMonth()+1; //January is 0! – Suresh Sapkota Aug 23 '17 at 01:23
  • U can see the link that i comment above. it's from different url. Nvm...i updated my answer. – asnawi Aug 23 '17 at 01:25
  • Thank you for updating the answer! – Suresh Sapkota Aug 23 '17 at 01:26