Skip to content

Instantly share code, notes, and snippets.

@nesffer
Last active March 2, 2023 07:45
Show Gist options
  • Save nesffer/9af5701fc8da277b376735a23e31e906 to your computer and use it in GitHub Desktop.
Save nesffer/9af5701fc8da277b376735a23e31e906 to your computer and use it in GitHub Desktop.
<html>
<h1>utc text 입력</h1>
시작시간: <input type="text" id="startInput"></input>
</br>
끝시간: <input type="text" id="textInput"></input>
</br>
<button id="inputBtn">변환</button>
<div id="result"><div>
</html>
<script>
const textInput = document.getElementById('textInput')
const inputBtn = document.getElementById('inputBtn')
const startInput = document.getElementById('startInput')
const result = document.getElementById('result')
inputBtn.addEventListener('click', (e) => {
const start = new Date(startInput.value)
console.log(startInput.value, start)
const d = new Date(textInput.value)
console.log(textInput.textContent, d)
result.textContent = `${textInput.value} = ${d.toLocaleString()}\n ${new Date(d-start).toISOString().substr(11, 8)}`
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment