Convert a specific date and time into UNIX epoch time (JS)

UNIX Epoch Time Convertor
The web tool has been developed using JavaScript, It's helps to convert human readable date and time into Epoch Time.
Javascript Code
Body
Date: <input id="t"type="date" name="bday">
Time: <input type="time" id="myTime" value="22:15:00">
<button onclick="myFunction()">Get EPOCH Time</button>
<p id="display"></p>
Javascript
<script>
function myFunction() {
var t = document.getElementById("t").value; // Get Date input value
var d = new Date(t);
var n = d.getTime(); // Return the number of milliseconds since 1970/01/01
var utd = n/1000; // Convert into seconds
var x = document.getElementById("myTime").value; // Get Time input value
var times = x.split(":");
var hour = times[0];
var minutes = times[1];
var o = (parseInt(hour, 10) * 3600) + (parseInt(minutes, 10) * 60); // Convert time into seconds
var tz = d.getTimezoneOffset(); // Timezoneoffset is the difference, in minutes, between UTC and local time
var tzsec = tz*60; // Convert time into seconds
var epoch = utd+o+tzsec; // Number of seconds that have elapsed since midnight, 1 January 1970
document.getElementById("demo").innerHTML = epoch; // Print EPOCH Time
}
</script>
Convert a specific date and time into UNIX epoch time (JS)
Reviewed by ABONZERTV
on
December 28, 2016
Rating: 5