今天被 chat 坑了
1 2 3 4 5 6 7
| # 错误的表达方式 int ms = 1000;
var format = DateFormat('HH:mm:ss'); var date = DateTime.fromMillisecondsSinceEpoch(ms); print(format.format(date)); // 00:00:01
|
1 2 3 4 5 6 7 8 9
| # 正确的方式 String timestampToTime(int timestamp) { print("timestamp : ${timestamp}"); int hour = (timestamp / 3600).toInt(); int minute = (timestamp / 60 /60).toInt(); int second = (timestamp%60).toInt();
return "${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}"; }
|
Author:
微笑城
Permalink:
http://www.yuelin.link/2023/02/23/flutter/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98/
License:
Copyright (c) 2019 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?