ntplib 모듈설치
pip install ntplib
NTP서버와 로컬간의 offset 체크
import ntplib
from time import ctime
timeServer = 'time.windows.com' # NTP Server Domain Or IP
c = ntplib.NTPClient()
response = c.request(timeServer, version=3)
print('NTP Server Time과 Local Time과 차이는 %.2f s입니다.' %response.offset)
--------------------------------------------------------------------
NTP Server Time과 Local Time과 차이는 0.71 s입니다.
NTP 서버시간 타임 스탬프로 출력
import ntplib
from time import ctime
timeServer = 'time.windows.com' # NTP Server Domain Or IP
c = ntplib.NTPClient()
response = c.request(timeServer, version=3)
print(ctime(response.tx_time))
---------------------------------------------------------------------
Mon May 21 11:20:51 2018
'Python > Python Programming' 카테고리의 다른 글
[ Python ] Linux 파일 (스토리지) 연도별 개수와 총 용량 구하기 (0) | 2023.05.24 |
---|---|
[ Python ] socket 모듈을 이용한 Port open / close check (0) | 2023.05.23 |
[ Python ] pandas DataFrame을 HTML 형식으로 export 하기. (모니터링 활용) (0) | 2023.05.17 |
[ Python ] 웹 서버 날짜 확인 하기 (0) | 2023.05.14 |
[ Python ] numpy를 이용한 1차원 배열 2 차원 배열로 변환 (0) | 2023.05.12 |
[ Python ] 날짜형식의 문자열 타입을 datetime 타입 형식으로 변환 (0) | 2023.05.03 |
[ Python ] xml 타입의 데이터 json 으로 변경 (0) | 2023.04.24 |
[ Python ] difflib 모듈 ( 문자열 비교, 유사도 ) (0) | 2023.04.24 |