+ 2

HOW DO I DISPLAY THE TIME??

I wrote this code but i dont know how to display the time in my output. Can anyone help? Here is the code in javascript function printTime() { var d = new Date(); var hour = d.getHours(); var mins = d.getMinutes(); var secs = d.getSeconds(); var year = d.getFullYear(); var month = d.getMonths(); var date = d.getDate(); var format = "<small> AM </small>"; format = (hours > 11)? "<small> PM </small>" format; if (hour > 12) { hour = hour - 12 ; } }

24th Nov 2017, 1:45 AM
Joar
Joar - avatar
4 Answers
24th Nov 2017, 2:54 AM
Daniel
Daniel - avatar
+ 1
I need to write it on the webpage body
24th Nov 2017, 5:28 AM
Joar
Joar - avatar
0
on webpage body or console log?
24th Nov 2017, 1:58 AM
CalviŐ˛
CalviŐ˛ - avatar
0
if you need to display it on a web page you have to write the appropriate HTML code.... if you need to display it on the console, just console.log() it
24th Nov 2017, 4:52 AM
Dmitrii
Dmitrii - avatar