Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 683 Bytes

Readme.md

File metadata and controls

43 lines (30 loc) · 683 Bytes

NTP

Simple implementation of NTP client

Install

go get github.com/haikelfazzani/ntpc

Usage

package main

import (
	"fmt"

	ntpc "github.com/haikelfazzani/ntpc/core"
)

func main() {
	ntpc := &ntpc.NewClient{
		Server:  "pool.ntp.org",
		Port:    "123",
		Timeout: 10,
	}

	timeNow, _ := ntpc.Query()
	fmt.Println("\n> NTP time:", timeNow.Local())

	dateTime := timeNow.Format("2006-01-02 15:04:05")

	isUpdated := ntpc.UpdateSystem(dateTime)
	fmt.Println("\n> System time updated:", isUpdated)
}

rfc5905 Public Time Servers

License

MIT