JSFiddle - React, Tailwind, and code Playground

HTML

<button id="test " onclick="generateTimeStamp()">
Click here
</button>

<script>
function generateTimeStamp(currentDate = null) {
  if (!currentDate) {
    let hours = Math.round(1+(23*Math.random()));
    console.log('hours is ' + hours.toString());
  } else {
    let hours = currentDate.getHours();
  }
  if (hours < 10) {hours = "0" + hours;}
  return hours;
}
</script>