Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get current timezone in flutter

I am new to flutter and my rest api takes current timezone as Europe/london. I don't know to get current timezone in flutter. There is a question in stackoverflow about this topic but no user gave the answer.

Flutter Timezone (as ZoneId)

Can anyone guide me, how can i get the current timezone in flutter using dart.

like image 367
Junaid Durrani Avatar asked Jan 14 '19 07:01

Junaid Durrani


1 Answers

DateTime is the default class give use timezone and time offset both required to solve timezone related issue.

 DateTime dateTime = DateTime.now();  print(dateTime.timeZoneName);  print(dateTime.timeZoneOffset); 

Output:

1. India

timeZoneName: IST timeZoneOffset: 5:30:00.000000 

2. America/Los_Angeles

timeZoneName: PST timeZoneOffset: -8:00:00.000000 

timezone list: https://help.syncfusion.com/flutter/calendar/timezone

like image 193
Jitesh Mohite Avatar answered Sep 21 '22 21:09

Jitesh Mohite