FILL DATE INPUT WITH FIRST AND LAST DAY OF CURRENT MONTH


/ Published in: JavaScript
Save to your folder(s)

Permet de préremplir des champs avec le premier et le dernier jour du mois courant au format jj/mm/aaaa


Copy this code and paste it in your HTML
  1. var date = new Date();
  2. var year = date.getFullYear();
  3. var month = date.getMonth()+1;
  4. var firstDay = "01";
  5. var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
  6. document.form.dateDebut.value = firstDay+"/"+month+"/"+year;
  7. document.form.dateFin.value = lastDay+"/"+month+"/"+year;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.