qhdkfq_regulatory_flutter/lib/tools/date_tool.dart

15 lines
417 B
Dart
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 获取当前年月字符串格式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');
}