Posted By

Igeco on 10/16/14


Tagged

form date input


Versions (?)

FILL DATE INPUT WITH FIRST AND LAST DAY OF CURRENT MONTH


 / Published in: JavaScript
 

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

  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  

You need to login to post a comment.