qhdkfq_regulatory_flutter/lib/tools/date_tool.dart

15 lines
417 B
Dart
Raw Normal View History

2025-07-09 14:31:12 +08:00
// 获取当前年月字符串格式2025-07
String getCurrentYearMonth() {
final now = DateTime.now();
return '${now.year}-${now.month.toString().padLeft(2, '0')}';
}
// 获取当前年份字符串
String getCurrentYear() {
return DateTime.now().year.toString();
}
// 获取当前月份字符串(带前导零)
String getCurrentMonth() {
return DateTime.now().month.toString().padLeft(2, '0');
}