Flutter Why tz.TZDatetime gives the device time?

110 Views Asked by At

I want to get the time right now in cairo but the timezone package give me the device date why ?

DateTime returnCommonDate(){
tz.initializeTimeZones();
final egyptTimeZone = 
tz.getLocation('Africa/Cairo');
final now = 
tz.TZDateTime.now(egyptTimeZone);
print"his is egypt time ${now}");
return now;

}

1

There are 1 best solutions below

3
Aftab Iqbal On

Try using the toLocal() function of the "timezone" package:

tz.TZDateTime.now(egyptTimeZone).toLocal()