Write a simple javascript function that displays the time wi

Write a simple javascript function that displays the time with AM or PM, date and day of the week.

Solution

Answer :

          function DTAMPM(date){

          var hours=date.getHours();

          var minutes=date.getMinutes();

          var ampm=hours >=12 ? \' pm \' : \' am \';

          hours=hours % 12;

         hours=hours ? hours : 12;

         minutes=minutes < 10 ? \' 0 \' +minutes : minutes;

          var strTime=hours + \' : \' + minutes + \' \' + ampm;

          return strTime;

    }

Write a simple javascript function that displays the time with AM or PM, date and day of the week.SolutionAnswer : function DTAMPM(date){ var hours=date.getHour

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site