Dart DateTime timeZoneName
Syntax & Examples


Syntax of DateTime.timeZoneName

The syntax of DateTime.timeZoneName property is:

 String timeZoneName 

This timeZoneName property of DateTime the time zone name.

Return Type

DateTime.timeZoneName returns value of type String.



✐ Example

1 Get the time zone name of the current date and time

In this example,

  1. We create a variable date representing the current date and time using DateTime.now().
  2. We access the timeZoneName property of date to get the time zone name, which is typically 'UTC' unless configured otherwise.
  3. We print the time zone name to standard output.

Dart Program

void main() {
  var date = DateTime.now();
  print(date.timeZoneName); // Output: UTC
}

Output

India Standard Time
Output varies depending on the current date and time.

Summary

In this Dart tutorial, we learned about timeZoneName property of DateTime: the syntax and few working examples with output and detailed explanation for each example.