A Canvas Problem

Hello everyone
Thanks for read my question
I code that:

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
</canvas>

<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");

ctx.font = "30px Arial";
setInterval(newmain, 1000);

function newmain() {
  main()
}
function main() {
  ctx.clearRect()
  var now = new Date();
  var hour = now.getHours();
  var minute = now.getMinutes();
  var second = now.getSeconds();
  var a = hour + ":" + minute + ":" + second;
  ctx.fillText(a ,10 ,50);
}
</script>

</body>
</html>

I want that canvas show the time now,example 11:35:26(with 11 is hours,35 is miunite, 26 is second)
But this don’t show anything in the canvas
Can you help me??
Thanks for reading :smiling_face_with_three_hearts:

Sorry everyone,now i can solve it :sweat_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.