如何在jquery中添加日期到datetime [英] How to add days to datetime in jquery

查看:153
本文介绍了如何在jquery中添加日期到datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 public static void Main(string [] args)
{

DateTime ToDayDate = DateTime.Now.Date;

DateTime RepayDate = DateTime.Parse(Console.ReadLine());

DateTime LoanExpiryDate = ToDayDate.AddDays(30);

if(RepayDate> LoanExpiryDate || RepayDate< ToDayDate)
{
Console.WriteLine(天数超过30天);
Console.ReadKey();
}
其他
{
Console.WriteLine(它的确定);
Console.ReadKey();
}
}





我尝试了什么:



请我刚开始编写JQuery,我可以很容易地将这些编写的c#代码归档,但无法在JQuery中的事件中归档。



请帮助JQuery保留。非常感谢



以下是我正在做的事情

 var d = new Date(); 
var month = d.getMonth()+ 1;
var day = d.getDate();

var o = {year:'numeric',month:'2-digit',day:'2-digit'};
var ToDayDate = d.toLocaleDateString('en-US',o);
console.log(value:+ ToDayDate)

解决方案

要为您的日期添加天数,你只是使用JavaScript而不是做任何jQuery特定的事情。这是一个简单的例子:

  const  newDate = d.setDate(d.getDate()+ numberOfDays); 


public static void Main(string[] args)
  {

      DateTime ToDayDate = DateTime.Now.Date;

      DateTime RepayDate = DateTime.Parse(Console.ReadLine());

      DateTime LoanExpiryDate = ToDayDate.AddDays(30);

      if (RepayDate > LoanExpiryDate || RepayDate < ToDayDate)
      {
          Console.WriteLine("The number of days is more than 30Days ");
          Console.ReadKey();
      }
      else
      {
          Console.WriteLine("its Ok ");
          Console.ReadKey();
      }
  }



What I have tried:

Please i'm new to writing JQuery, I could easily archive this writing c# codes but could not archive the same on an event in JQuery.

Please kindly help with the reserve in JQuery. Thanks alot

Below is what i was doing

var d = new Date();
var month = d.getMonth() + 1;
var day = d.getDate();

var o = { year: 'numeric', month: '2-digit', day: '2-digit'};
var ToDayDate = d.toLocaleDateString('en-US', o);
console.log("value: " + ToDayDate)

解决方案

To add days to your date, you're just using JavaScript rather than doing anything jQuery specific. It's a simple case of doing

const newDate = d.setDate(d.getDate() + numberOfDays);


这篇关于如何在jquery中添加日期到datetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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