Skip to content

haikelfazzani/ntpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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

About

๐Ÿ•š NTP (Network Time Protocol) client

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages