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,
- We create a variable
date
representing the current date and time usingDateTime.now()
. - We access the
timeZoneName
property ofdate
to get the time zone name, which is typically 'UTC' unless configured otherwise. - 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.