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,

  1. We create a DateTime object now with the current date and time using DateTime.now().
  2. We access the microsecond property of now to get the current microsecond value.
  3. 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.