Please don't suggest any libraries or any node.js stuff. I want to be able to find a method that is based on pure plain JavaScript OK
so I'm creating a feature on my website that coverts past time and date from the one-time zone into another time zone. For example, I have this time and date from mountain standard time (MST). 6/29/2011 4:52 PM
and I want to know what time and date it was at that moment in Arabia Standard Time (AST).
I know that the date may be different because countries on earth is a day ahead or behind from other countries. I just can't figure out how this can be done in plain JavaScript.
This is my code so far
//???
#container{
background-color: red;
display: inline-block;
margin-bottom: 20px;
padding: 8px;
border-radius: 8px;
}
input{
display: block;
margin-bottom: 10px;
}
p{
margin-bottom: 0;
}
<h1>Convert past date and time from one time zone into another.</h1>
<div id='container'>
<p>Date</p>
<input type='text' id='date' value='6-29-2011'>
<p>Time</p>
<input type='text' id='time' value='4:52 PM'>
<p>Time zone</p>
<input type='text' id='time-zone' value='MST'>
<p>Convert into this time zone</p>
<input type='text' value='AST'>
<p>Result</p>
<em id='result'></em>
</div>
According to this time zone converter website https://www.timeanddate.com/worldclock/converter.html This will be the converted time and date 6/29/2011 4:52 PM MST and in AST 6/30/2011 1:52 AM