这是持续时间。
例如:
void main(List<String> args) {
// Define two dates.
DateTime date1 = new DateTime(2010, 1, 1, 8, 0, 15);
DateTime date2 = new DateTime(2010, 8, 18, 13, 30, 30);
// Calculate the interval between the two dates.
Duration interval = date2.difference(date1);
print('$date2 - $date1 = $interval');
// Display individual properties of the resulting TimeSpan object.
print('Total Number of Days: ${interval.inDays}');
print('Total Number of Hours: ${interval.inHours}');
print('Total Number of Minutes: ${interval.inMinutes}');
print('Total Number of Seconds: ${interval.inSeconds}');
print('Total Number of Milliseconds: ${interval.inMilliseconds}');
}
Run Code Online (Sandbox Code Playgroud)
结果将是:
2010-08-18 13:30:30.000 - 2010-01-01 08:00:15.000 = 5501:30:15.000000
Total Number of Days: 229
Total Number of Hours: 5501
Total Number of Minutes: 330090
Total Number of Seconds: 19805415
Total Number of Milliseconds: 19805415000
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1906 次 |
| 最近记录: |