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

outdated

Fetch accurate time or current DateTime object from (NTP) Network Time Protocol server.

example/main.dart

import 'package:ntp/ntp.dart';

void main() async {
  DateTime _myTime;
  DateTime _ntpTime;

  /// Or you could get NTP current (It will call DateTime.now() and add NTP offset to it)
  _myTime = await NTP.now();

  /// Or get NTP offset (in milliseconds) and add it yourself
  final int offset = await NTP.getNtpOffset(localTime: DateTime.now());
  _ntpTime = _myTime.add(Duration(milliseconds: offset));

  print('My time: $_myTime');
  print('NTP time: $_ntpTime');
  print('Difference: ${_myTime.difference(_ntpTime).inMilliseconds}ms');
}
214
likes
0
pub points
98%
popularity

Publisher

verified publishersquare-pear.com

Fetch accurate time or current DateTime object from (NTP) Network Time Protocol server.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on ntp