我有一个日历,我想在日历上方显示月份。无论如何只能显示当前月份吗?
(图片归功于https://github.com/adamstyrc/)
它应该是这样的:
将以下包用于 DateFormat。
String returnMonth(DateTime date) {
return new DateFormat.MMMM().format(date);
}
Run Code Online (Sandbox Code Playgroud)
只需传递日期,该函数将返回 Month。例如。四、一月
import 'package:intl/intl.dart';
List months =
['jan', 'feb', 'mar', 'apr', 'may','jun','jul','aug','sep','oct','nov','dec'];
var now = new DateTime.now();
current_mon = now.month;
print(months[current_mon-1]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7156 次 |
| 最近记录: |