Time Conversion Script - Free Unit Converter

Script that converts between different time units. Select the time unit to convert in the select box. Enter the value to convert in the input field and click on convert button. The conversion result will immediately appear in the output field.

Features

  • Simple and efficient script for time conversion.
  • Ease of use
  • Just copy & paste the code into your page to use the converter.

Preview

Select Your Option
Input:
Output:

Downloads

Javascript


<!-- Script by hscripts.com -->

<script type="text/JavaScript">
function calculate(){var val;
val=document.getElementById('opt').value;var inp=document.getElementById('field1').value;if(val==0){var op=inp*60;document.getElementById('field2').value=op " minutes";}else if(val==1){var op=inp*3600;
document.getElementById('field2').value=op " Seconds";}else if(val==2){var op=inp/60;var op1=formatNumber(op, 4);
document.getElementById('field2').value=op1 " Hours";}else if(val==3){var op=inp*60;
document.getElementById('field2').value=op " Seconds";}else if(val==4){var op=inp/3600;var op1=formatNumber(op, 4);
document.getElementById('field2').value=op1 " Hours";}else if(val==5){var op=inp/60;var op1=formatNumber(op, 4);
document.getElementById('field2').value=op1 " Minutes";}function formatNumber(myNum, numOfDec){var decimal = 1;for(i=1; i<=numOfDec;i
)decimal = decimal *10var myFormattedNum = (Math.round(myNum * decimal)/decimal).toFixed(numOfDec)
return(myFormattedNum);} }function isNumberKey(evt){var charCode = (evt.which) ? evt.which : event.keyCodeif (charCode > 31 && (charCode < 48 || charCode > 57)){alert("Enter only numbers");return false;}return true;}function stop(){alert("please provide your input in the input field");return false;}
</script>
<!-- Script by hscripts.com -->



HTML Code


<font color="brown" style=font-family:"Times New Roman",Georgia,Serif;><b>Select Your Option</b></font><select name="opt" id="opt"><option value="0">Hours to minutes</option><option value="1">Hours to Seconds</option><option value="2">minutes to Hours</option><option value="3">minutes to Seconds</option><option value="4">Seconds to hours</option><option value="5">seconds to minutes</option>
</select><br><br><div style="padding-left:80px;">
<font style=font-family:"Times New Roman",Georgia,Serif;>Input:</font><input type="text" name="field1" id="field1" onkeypress="return isNumberKey(event)"></div>
<br><div style="padding-left:70px;">
<font style=font-family:"Times New Roman",Georgia,Serif;>Output:</font><input type="text" name="field2" id="field2" onkeypress="return stop()"></div><br><input type="button" value="convert" onclick="calculate()">

  • Release Date - 02-06-2010
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy and paste the html code into the <body> tag of your page.
  • Copy the javascript code into <head> tag of your page.
  • The function "calculate()" is used to convert the one form of the time unit into another.
  • Make use of this Converter script and Convert your time entities as you wish.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question