자바스크립트로 서버 시간 읽기

HTTP HEAD를 사용하여 서버 시간을 읽는다.

Photo by Icons8 Team on Unsplash
fetch('/', { method: 'HEAD' })
.then((r) => {
console.log(r.headers.get('date'))
})
const axios = require('axios')
axios
.head('https://afrontend.medium.com/')
.then(res => {
console.log(res.headers.date)
})
.catch(error => {
console.error(error)
})
curl --HEAD afrontend.medium.com 2>&1 | grep Date
Date: Fri, 12 Nov 2021 03:23:23 GMT

--

--

JavaScript Developer, https://afrontend.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store