时间:2022-11-15 09:47:51 | 栏目:Android代码 | 点击:次
var now=new DateTime.now(); print(now.millisecondsSinceEpoch); //单位毫秒,13位时间戳
var now=new DateTime.now(); var a=now.millisecondsSinceEpoch; // 时间戳* print(DateTime.fromMillisecondsSinceEpoch(a));
DateTime assignDay = new DateTime(2020,10,10); print(assignDay); // 2020-10-10 00:00:00.000
// 例如计算1天14小时45分的跨度 Duration timeRemaining = new Duration(days:1, hours:14, minutes:45); print(timeRemaining); // 38:45:00.000000
DateTime.parse('2019-11-08') //或者 DateTime.parse('2019-11-08 12:30:05')
var today = DateTime.now(); var date = DateTime.parse("2019-06-20 15:32:41"); today.isBefore(date);
var today = DateTime.now(); var date = DateTime.parse("2019-06-20 15:32:41"); today.isAfter(date);
var today = DateTime.now(); var date = DateTime.parse("2019-06-20 15:32:41"); today.isAtSameMomentAs(date);
var today = DateTime.now(); // 2019-11-08 02:54:53.218443 var fiftyDaysFromNow = today.add(new Duration(days: 5)); print('today加5天:$fiftyDaysFromNow'); // today加5天:2019-11-13 02:54:53.218443
var today = DateTime.now(); // 2019-11-08 02:54:53.218443 var fiftyDaysAgo = today.add(new Duration(days: 5)); print('today加5天:$fiftyDaysAgo '); // today减5天:2019-11-03 02:54:53.218443
var day1 = new DateTime(2019, 6, 20, 17, 30, 20); var day2 = new DateTime(2019, 7, 21, 0, 0, 0); print('比较两个时间 差 小时数:${day1.difference(day2)}'); // 比较两个时间 差 小时数:-726:29:40.000000
year、month、day、weekday、hour、minute、second、millisecond、microsecond var today = DateTime.now(); print(today.year);
DateTime today = DateTime.now(); print('本地时区简码:${today.timeZoneName}'); // 本地时区简码:GMT
DateTime today = DateTime.now(); print('返回UTC与本地时差 小时数:${today.timeZoneOffset}');