There are always 12 months in a year, so early C implementations might have used a static fixed-width array with indexes 0,1,2..11. Let see the example, //START DATE CONSTRUCTOR //IF MONTH AND DAY LESS THEN 9, IT SHOULD BE 01, 02,...,09 var zerofill = function ( i ) { return ( i < 10 ? '0' : '' ) + i ; } var getDateString = function ( date ) { if ( date != undefined && date != null ) { var d = zerofill ( date . getDate ()); var m = zerofill ( date . getMonth () + 1 ); ////Month from 0 to 11, so added 1 months var y = date . getFullYear (); return d + "/" + m + "/" + y ; } } var nowDate = new Date (); //CALL DATE STRING with DD/MM/YYYY format getDateString ( nowDate ); //END DAT...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers