ntp 1.0.0 copy "ntp: ^1.0.0" to clipboard
ntp: ^1.0.0 copied to clipboard

outdated

Fetch accurate time from NTP server

pub package

ntp #

Plugin that allows you to get precise time from Network Time Protocol (NTP). Whole NTP protocol is implemented in dart.

By default lookup address for NTP is: pool.ntp.org

How it works #

Using int offset from getNtpTime()

  • default localTime is DateTime.now()
  • default lookUpAddress is 'pool.ntp.org'
  • default port is 123
  DateTime startDate = new DateTime().now().toLocal();
  int offset = await NTP.getNtpTime(localTime: startDate);
  print('NTP DateTime offset align: ${startDate.add(new Duration(milliseconds: offset))}');

Using DateTime from now

  DateTime startDate = await NTP.now();
  print('NTP DateTime: ${startDate}');

NTP Functions #

  Future<int> getNtpTime({
    String lookUpAddress: 'pool.ntp.org',
    int port: 123,
    DateTime localTime,
  });
  Future<DateTime> now();
213
likes
0
pub points
98%
popularity

Publisher

verified publishersquare-pear.com

Fetch accurate time from NTP server

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on ntp