.getutc()日期,如果月末 [英] .getutc( ) date if end of the month

查看:56
本文介绍了.getutc()日期,如果月末的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个日期:开始日期和结束日期以及基于这些日期的现金流量,具体取决于用户输入。



如果一个人不想进入开始日期,它将采用结束日期并打印现金流。

示例:结束日=当月5日,然后开始日期始终(结束日期+ 1天),即月份的第6个月。



现在我的代码工作正常,如果它是月末或31,那么它打印第32个开始日期是不正确的。它应该是第一个,因为它是新月。我如何在我的代码中使用该条件?任何帮助将不胜感激。谢谢。



我尝试了什么:



 if(startDate == null){
sDay = endDate.getUTCDate()+ 1;
}

解决方案

参见 JavaScript setUTCDate()方法 [ ^ ]

I have 2 dates : Start date and end date and cash flows based on those dates depending on user input.

If a person doesn't want to enter start date, it will take the end date and print the cash flows.
Example: End Day = 5th of the month, then start date is always (end date + 1 day) i.e. 6th of the month.

Right now my code is working however, if it's the end of the month or 31st, then it's printing 32nd for start date which is incorrect. It should be the 1st since it's the new month. How do i use that condition inside my code? Any help will be greatly appreciated. Thank you.

What I have tried:

if (startDate == null) {
  sDay = endDate.getUTCDate()+1;
}

解决方案

See JavaScript setUTCDate() Method[^].


这篇关于.getutc()日期,如果月末的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆