angular - 需要以角度 7 传递当前日期的最后一天
问题描述
我正在尝试以短日期格式将日期传递给我的角度应用程序中的方法,但日期必须是本月的最后一天。我怎么做
这就是我所做的
import {formatDate} from '@angular/common';
this.allocationsComponent.getAllocationsDetails(formatDate(new Date(), 'yyyy/MM/dd', 'en'));
结果是
2019/04/02
解决方案
试试这个:
var today = new Date();
var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0);
this.allocationsComponent.getAllocationsDetails(formatDate(lastDayOfMonth, 'yyyy/MM/dd', 'en'));
推荐阅读
- c++ - 对象创建错误的 C++ 向量
- cordova - 任务 ':app:processDebugGoogleServices' 执行失败,寻找 google-services.json 并没有成功找到它
- mysql - 如何将查询产生的表连接到存储在 mysql 上的过程的另一个临时表中?
- android - 设置中的Android“语音输入”选项丢失
- javascript - 基于嵌套属性过滤数组
- php - 我的 php 文件中的错误我似乎找不到?也许是由ajax引起的?
- python - Pandas:在检查另一列的成员资格时创建 NaN?
- c - C 冒泡排序最大的值变成0
- javascript - 减少 setState 中的计数器
- sql - 使用 SQL 创建 ID X-ref 表