Home > Net >  How do I check if the system date is correct in flutter? Any package or API
How do I check if the system date is correct in flutter? Any package or API

Time:06-10

Is there any way to check if the system DateTime is correct or not in Flutter? I tried searching for APIs which provide current DateTime, but the problem with timezones happens again. What is the solution for this? (I want to do something like WhatsApp. which is, don't give chatting access if system DateTime is wrong)

CodePudding user response:

simple solution, use unix epoch time

print(DateTime.now().millisecondsSinceEpoch);

CodePudding user response:

you can use ntp plugin

var nowInternet = await NTP.now();
var now = DateTime.now();
print(nowInternet);
print(now);
//check diff is grater than 1 minute
if (nowInternet.difference(now).inMinutes < 1){
   //good
}
  • Related