Dart DateTime microsecond
Syntax & Examples
Syntax of DateTime.microsecond
The syntax of DateTime.microsecond property is:
int microsecond
This microsecond property of DateTime the microsecond [0...999]
.
Return Type
DateTime.microsecond returns value of type int
.
✐ Example
1 Get current microsecond
In this example,
- We create a DateTime object
now
with the current date and time usingDateTime.now()
. - We access the
microsecond
property ofnow
to get the current microsecond value. - We print the current microsecond value to standard output.
Dart Program
void main() {
DateTime now = DateTime.now();
int currentMicrosecond = now.microsecond;
print('Current microsecond: $currentMicrosecond');
}
Output
Current microsecond: 0
Summary
In this Dart tutorial, we learned about microsecond property of DateTime: the syntax and few working examples with output and detailed explanation for each example.