如何在我的代码中放置两个毫秒转换日期
这种编码方式正确吗?如何显示 2 个日期。有人可以帮助我检查和纠正我的编码吗? int ts=1646274840000; int ts2=1646015654686;
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'api_service.dart';
class AppoinmentList extends StatefulWidget {
final String? token;
AppoinmentList({
Key? key,
this.token
}) : super(key: key);
@override
_AppoinmentListState createState() => _AppoinmentListState();
}
class _AppoinmentListState extends State<AppoinmentList> {
@override
void initState() {
super.initState();
APIService.getAppointmentList(widget.token!);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Appointment Listing"),
),
body: _time()
);
//body: _appoinmentListUI(),
}
}
_time() {
int ts=1646274840000;
int ts2=1646015654686;
DateTime tsdate = DateTime.fromMillisecondsSinceEpoch(ts);
DateTime ts2date = DateTime.fromMillisecondsSinceEpoch(ts2);
String fdatetime = DateFormat('MM/dd/yyyy, hh:mm a').format(tsdate);
String fdatetime2 = DateFormat('MM/dd/yyyy, hh:mm a').format(ts2date);
return Container(
child: Text(fdatetime,),
);
}
我只成功地显示了一个日期的输出。如何显示两个日期?有人可以帮助我。
此输出仅显示一个日期
Is this way of coding correct, and how do show 2 dates. Can someone help me to check and correct my coding? int ts=1646274840000; int ts2=1646015654686;
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'api_service.dart';
class AppoinmentList extends StatefulWidget {
final String? token;
AppoinmentList({
Key? key,
this.token
}) : super(key: key);
@override
_AppoinmentListState createState() => _AppoinmentListState();
}
class _AppoinmentListState extends State<AppoinmentList> {
@override
void initState() {
super.initState();
APIService.getAppointmentList(widget.token!);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Appointment Listing"),
),
body: _time()
);
//body: _appoinmentListUI(),
}
}
_time() {
int ts=1646274840000;
int ts2=1646015654686;
DateTime tsdate = DateTime.fromMillisecondsSinceEpoch(ts);
DateTime ts2date = DateTime.fromMillisecondsSinceEpoch(ts2);
String fdatetime = DateFormat('MM/dd/yyyy, hh:mm a').format(tsdate);
String fdatetime2 = DateFormat('MM/dd/yyyy, hh:mm a').format(ts2date);
return Container(
child: Text(fdatetime,),
);
}
I only success to show the output for one date only. How to show two dates? Someone can help me.
This output show for one date only
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
_time()
仅返回第一个日期的一个Text
小部件。您需要为第二次约会添加另一个。将两个
Text
小部件放入Column< /code>
如果您希望它们彼此重叠。
像这样:
_time()
only returns oneText
widget for the first date. You need to add another one for the second date.Put both
Text
widgets in aColumn
if you want them on top of each other.like this: