我一直在学习Dart,但我不知道如何生成时间戳.我试过:
void main() {
print((new Date()).millisecondsSinceEpoch);
}
多亏了IDE,我才能走到这一步,但是 我收到一个令人困惑的错误:
Exception: No such method: 'Date'
帮助?
我一直在学习Dart,但我不知道如何生成时间戳.我试过:
void main() {
print((new Date()).millisecondsSinceEpoch);
}
多亏了IDE,我才能走到这一步,但是 我收到一个令人困惑的错误:
Exception: No such method: 'Date'
帮助?
你差点说对了.你只是没有使用named constructor:
void main() {
print(DateTime.now().millisecondsSinceEpoch);
}
给予:
1351441456747
更多信息请参见API文档:https://api.dart.dev/stable/2.10.1/dart-core/DateTime-class.html