Skip to content

Instantly share code, notes, and snippets.

Last active March 2, 2023 07:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<h1>utc text 입력</h1>
시작시간: <input type="text" id="startInput"></input>
끝시간: <input type="text" id="textInput"></input>
<button id="inputBtn">변환</button>
<div id="result"><div>
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)}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment