'Flutter TZDateTime returning current time
I am working with https://github.com/MaikuB/flutter_local_notifications and trying to add a zonedShedule-Notification. For that I need TZDateTime. The problem is that it is always retuning the UTC-Time... But I actually need the ESCT.
To get the current time I am using this line:
final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
I couldn't find anything to convert TZDateTime to the current Local Time... I am happy for every help! Let me know if you need any more info.
Solution 1:[1]
I had exactly the same problem.
When initializating the plugin, initialize the time zones, too.
tz.initializeTimeZones();
final String timeZone = await FlutterNativeTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(timeZone));
Install package flutter_native_timezone to get your local time zone. Then it should work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | xmashallax |
