添加到ddmmyyyy日期 [英] adding to a ddmmyyyy date

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

问题描述

大家好。


我在添加日期时遇到问题。


我的日期是字符串格式dd / mm / yyyy例如。 2007年8月23日在我的

表格字段中。


我不知道如何在该日期添加50天然后将其写入

另一个表格字段。


任何帮助都将不胜感激。

Hi All.

I''m having a problem adding days to a date.

My date is in the string format dd/mm/yyyy eg. 23/08/2007 in my
form field.

I can''t work out how to add 50 days to that date and then write it to
another form field.

Any help would be appreciated.

推荐答案

8月8日凌晨3:16,ginajohnst< ginajoh ... @ gmail.comwrote:
On Aug 8, 3:16 am, ginajohnst <ginajoh...@gmail.comwrote:

大家好。


我在将日期添加到日期时遇到问题。


我的日期是字符串格式dd / mm / yyyy例如。 2007年8月23日在我的

表格字段中。


我不知道如何在该日期添加50天然后将其写入

另一个表格字段。


任何帮助将不胜感激。
Hi All.

I''m having a problem adding days to a date.

My date is in the string format dd/mm/yyyy eg. 23/08/2007 in my
form field.

I can''t work out how to add 50 days to that date and then write it to
another form field.

Any help would be appreciated.



你能想出哪一部分?请参阅FAQ以了解日期操作。

要更改表单元素的值,请设置其value属性。

Which part can''t you figure out? See the FAQ for date manipulation.
To change a form element''s value, set its value property.


In comp.lang.javascript消息< 46 ************** @ PointedEars.de>,星期三,

2007年8月8日10:42:09,Thomas' 'PointedEars''Lahn< Po ********* @ web.de>

发布:
In comp.lang.javascript message <46**************@PointedEars.de>, Wed,
8 Aug 2007 10:42:09, Thomas ''PointedEars'' Lahn <Po*********@web.de>
posted:

> Quickhack:
>Quickhack:



但未经过充分测试。它给了

23/02/2007 + 50 -12/04/2007

23/08/2007 + 50 -12/10/2007


但是2月比8月短,应该再给3天。

but not well tested. It gives
23/02/2007 + 50 -12/04/2007
23/08/2007 + 50 -12/10/2007

But February is shorter than August, and should give days 3 more.


var

a = formField.value。 split("),

d = new Date(

parseInt(a [2],10),parseInt(a [1],10),parseInt (a [0],10)+ 50);
var
a = formField.value.split("/"),
d = new Date(
parseInt(a[2], 10), parseInt(a[1], 10), parseInt(a[0], 10) + 50);



d = new Date(a [2],a [1] -1,a [0] +50)//就够了


在这种情况下,可以用一元+替换parseInt;这将在

上下文中有效隐含。

d = new Date(a[2], a[1]-1, a[0]+50) // suffices

One can replace, in this context, parseInt by unary +; and that will in
context be effectively implicit.


anotherFormField.value =

String(d.getDate ()* 1e6 + d.getMonth()* 1e4 + d.getFullYear())

.replace(/(\\\)(\\\)(\ d {4})/,"
anotherFormField.value =
String(d.getDate() * 1e6 + d.getMonth() * 1e4 + d.getFullYear())
.replace(/(\d\d)(\d\d)(\d{4})/, "


1 /


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

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