<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<p></p>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<div class="ui input"><input id="typeIntInput" type="number" placeholder="숫자를 입력하세요" /><button id="typeIntButton" class="ui primary button">변환</button></div>
<p> </p>
<div class="ui statistic">
<div id="resultDate" class="value"> </div>
<br />
<div class="label">변환 값 입니다.</div>
</div>
<p><br /><br /></p>
<div class="ui input"><input id="typeDateInput" type="datetime-local" placeholder="날짜를 입력하세요" /><button id="typeDateButton" class="ui primary button">변환</button></div>
<p> </p>
<div class="ui statistic">
<div id="resultInt" class="value"> </div>
<br />
<div class="label">변환 값 입니다.</div>
</div>
<script>
const typeIntButton = document.getElementById('typeIntButton');
const typeDateButton = document.getElementById('typeDateButton');
const typeDateInput = document.getElementById('typeDateInput');
const typeIntInput = document.getElementById('typeIntInput');
const resultDate = document.getElementById('resultDate');
const resultInt = document.getElementById('resultInt');
typeIntButton.onclick = function(){
let result = parseInt(typeIntInput.value);
try{
resultDate.innerHTML = new Date(result);
typeIntInput.value = '';
}catch(e){
resultDate.innerHTML = '올바른 값을 입력해주세요 에러코드 =>'+e;
}
}
typeDateButton.onclick = function(){
let result = Date.parse(typeDateInput.value);
try{
resultInt.innerHTML = result;
typeDateInput.value = '';
}catch(e){
resultInt.innerHTML = '올바른 값을 입력해주세요 에러코드 =>'+e;
}
}
</script>
변환 값 입니다.
변환 값 입니다.
댓글