Date and Time Units Converter

Date and Time Units Converter

If you are looking for Date and Time Units Converter then you are at the right place. For this article, we are going to learn on how to create a converter for Date and Time. This source code converts From date/time format To the other date/time format. The user allows entering the numeric value and choose the formats either Seconds, Minute, Hour, Day, Week, Month, or Year and convert to the other one format.

For Example

We are going to set 48 Hour and convert to Day. So, let's see what's the result. Result

Example Source Code

  1. <form method="post">
  2. <table align="center" cellspacing="5" cellpadding="5" border="1" style="width: 458px; border:1px solid blue; font-family:cursive; height: 87px;">
  3.         <tr>
  4.                 <td style="text-align: center; color:blue; width: 228px; font-size: 35px; height: 29px; background-color: azure;">
  5.                         From
  6.                 </td>
  7.                 <td style="text-align: center; color:blue; width: 228px; font-size: 35px; height: 29px; background-color: azure;">
  8.                         To
  9.                 </td>
  10.         </tr>
  11.         <tr>
  12.                 <td style="text-align: center; width: 228px; height: 29px; background-color:azure;">
  13.                         <select name="sFrom" style="width: 178px; font-size: 18px; border:1px solid blue; font-family:cursive;">
  14.                         <?php
  15.                         echo("
  16.                                 <option $t1>Second</option>
  17.                                 <option $t2>Minute</option>
  18.                                 <option $t3>Hour</option>
  19.                                 <option $t4>Day</option>
  20.                                 <option $t5>Week</option>
  21.                                 <option $t6>Month</option>
  22.                                 <option $t7>Year</option>
  23.                         ")
  24.                         ?>
  25.                         </select>
  26.                 </td>
  27.                 <td style="text-align: center; width: 228px; height: 29px; background-color:azure;">
  28.                         <select name="sTo" style="width: 178px; font-size: 18px; border:1px solid blue; font-family:cursive;">
  29.                         <?php
  30.                         echo("
  31.                                 <option $s1>Second</option>
  32.                                 <option $s2>Minute</option>
  33.                                 <option $s3>Hour</option>
  34.                                 <option $s4>Day</option>
  35.                                 <option $s5>Week</option>
  36.                                 <option $s6>Month</option>
  37.                                 <option $s7>Year</option>
  38.                         ")
  39.                         ?>
  40.                         </select>
  41.                 </td>
  42.         </tr>
  43.         <tr>
  44.                 <td style="text-align: center; width: 228; height: 43; background-color:azure;">
  45.                         <input name="tFrom" autofocus="autofocus" style="width: 178px; text-indent:5px; height: 28px; font-family:cursive; font-size: 18px; margin-bottom: 5px" value="<?php if (isset($_POST['Submit'])) echo $_POST['tFrom'] ?>">
  46.                 </td>
  47.                 <td align="center"  style="text-align: center; width: 228; height: 43; background-color:azure;">
  48.                         <div align="center" ><label id="Label1" style="width: 178px; border:1px solid blue; height: 28px; font-family:cursive; font-size: 18px; margin-bottom: 5px; background-color: #FAFAFA; display: block;"><?php echo $to?></label></div>
  49.                 </td>
  50.         </tr>
  51.  
  52. <br />
  53. <br />
  54.  
  55.         <div style="text-align: center">
  56.                 <input name="Submit" type="submit" value="Convert" style="width: 107px; height: 38px; background:azure; color:blue; border:1px solid blue; border-radius:8px; cursor:pointer; font-family:cursive; font-size: 25px">
  57.         </div>
  58. </form>
So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment