exact time upon button click - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

exact time upon button click

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Button Click</title> 
      <script type="text/javascript">
      function filter_seconds(date){
          return date.replace(/(\d{1,2}\:\d{1,2})\:\d{2}/, '$1')
      }//ww  w .  ja  v  a2 s.c om
    
      </script> 
   </head> 
   <body> 
      <input type="text" id="date" value=""> 
      <input id="button" 
             type="button" 
             value="Get the Date!" 
             onclick="document.getElementById('date').value = filter_seconds(new Date().toLocaleTimeString(navigator.language))">  
   </body>
</html>

Related Tutorials