56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
|
|
import 'package:date_format/date_format.dart';
|
|
|
|
class DateTool {
|
|
|
|
String getNowDateYMDHM(){
|
|
// 获取当前时间对象
|
|
DateTime now = DateTime.now();
|
|
|
|
//获取当前时间的年
|
|
int year = now.year;
|
|
//获取当前时间的月
|
|
int month = now.month;
|
|
//获取当前时间的日
|
|
int day = now.day;
|
|
//获取当前时间的时
|
|
int hour = now.hour;
|
|
//获取当前时间的分
|
|
int minute = now.minute;
|
|
//获取当前时间的秒
|
|
int millisecond = now.millisecond;
|
|
|
|
// print("组合 $year-$month-$day $hour:$minute:$millisecond");
|
|
return "$year.$month.$day $hour:$minute";
|
|
}
|
|
|
|
String dateToYMDHNSString(String timeDate){
|
|
int time = int.parse(timeDate);
|
|
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
|
String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn ,':',ss]);
|
|
return appointmentDate;
|
|
}
|
|
|
|
String dateToYMDHNString(String timeDate){
|
|
int time = int.parse(timeDate);
|
|
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
|
|
|
String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn]);
|
|
|
|
return appointmentDate;
|
|
}
|
|
|
|
String dateToYMDString(String timeDate){
|
|
int time = int.parse(timeDate);
|
|
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
|
String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd]);
|
|
return appointmentDate;
|
|
}
|
|
|
|
String dateToHNString(String timeDate){
|
|
int time = int.parse(timeDate);
|
|
DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time);
|
|
String appointmentDate = formatDate(nowDate, [HH,':',nn]);
|
|
return appointmentDate;
|
|
}
|
|
} |