Javascript和使用日期 [英] Javascript and working with dates
问题描述
我需要写一些javascript来返回
格式的日期字符串mm / dd / yyyy。
日期需要是今天's date - 30天。
有没有比较直接的方法呢?
到目前为止,我能找到的只是一个月,一天和一年的变量,
并将一些日期函数组合在一起等等。好像很多
的工作应该是非常简单的。
rhaazyaécrit:
我需要编写一些javascript返回
表格中的日期字符串mm / dd / yyyy。
日期需要是今天的日期 - 30天。
有没有相对直接的方法来做到这一点?
http:// www.merlyn.demon.co.uk/js-date1.htm#incr
到目前为止,我能找到的是一堆乱七八糟的变数,日和年,
并将一些日期功能组合在一起等等。看起来像很多
的工作应该非常简单。
如果我们想要法语日期,您认为我们必须做什么?
dd / mm / yyyy
var D =新日期();
D.setMonth(D.getMonth() - 1)
alert(D.getDate( )+''/''+(+ D.getMonth()+ 1)+''/''+ D.getFullYear());
- 19/8 / 2008
-
sm
9月19日下午3:04 *,SAM < stephanemoriaux.NoAd ... @ wanadoo.fr.invalid>
写道:
rhaazyaécrit:
< blockquote class =post_quotes>
我需要写一些javascript来返回
格式的日期字符串mm / dd / yyyy。
日期需要是今天的日期--30天。
有没有比较直接的方法呢?
http://www.merlyn.demon.co.uk/js-date1.htm#incr
到目前为止我所能找到的只是一团糟月,日和年的变量,
并将一些日期函数组合在一起等等。*好像很多
的工作应该非常简单。
如果我们想要法语日期,您认为我们必须做什么?
* dd / mm / yyyy >
var D =新日期();
D.setMonth(D.getMonth() - 1)
alert(D.getDate ()+''/''+(+ D.getMonth()+ 1)+''/''+ D.getFullYear());
* --19 / 8/2008
-
sm
如果我想要的只是一个,那就太好了日期,但是能够从任何给定的日期减去30天
引入了大量的逻辑,需要
编码。
我决定只为我的目的找到一个开源日期库,它有一个不错的
解析函数。
感谢您的帖子。
rhaazy< rh **** @ gmail.comwrites:
9月19日,3:04?* pm,SAM < stephanemoriaux.NoAd ... @ wanadoo.fr.invalid>
写道:
多数民众赞成如果我想要的只是约会,但是能够ubtract 30天
从任何给定的日期开始引入一大堆逻辑需要
编码。
这是因为日期和时间非常混乱。一个能够
的库可以操作完全足够/全局/有用的日期
非常大。例如,参见perl DateTime
项目中的东西数量:
http://datetime.perl.org/?Modules
我决定找一个开源日期库为了我的目的,它有很好的解析功能。
如果你能找到一个不错的图书馆,这可能是解决这个问题的最佳方式。
-
Joost Diepenmaat |博客: http://joost.zeekat.nl/ |工作: http://zeekat.nl/
>
I need to write some javascript that will return a date string in the
form mm/dd/yyyy.
The date needs to be today''s date - 30 days.
Is there a relatively straight forward way to do this?
So far all I can find is a mess of variables for month, day, and year,
and combining some date functions together, etc etc. Seems like a lot
of work for what should be very simple.
rhaazy a écrit :I need to write some javascript that will return a date string in the
form mm/dd/yyyy.
The date needs to be today''s date - 30 days.
Is there a relatively straight forward way to do this?http://www.merlyn.demon.co.uk/js-date1.htm#incr
So far all I can find is a mess of variables for month, day, and year,
and combining some date functions together, etc etc. Seems like a lot
of work for what should be very simple.
and what do you think we have to do when we want the date in french ?
dd/mm/yyyy
var D = new Date();
D.setMonth(D.getMonth()-1)
alert( D.getDate()+''/''+(+D.getMonth()+1)+''/''+D.getFullYear() );
--19/8/2008
--
sm
On Sep 19, 3:04*pm, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:rhaazy a écrit :
I need to write some javascript that will return a date string in the
form mm/dd/yyyy.
The date needs to be today''s date - 30 days.
Is there a relatively straight forward way to do this?
http://www.merlyn.demon.co.uk/js-date1.htm#incr
So far all I can find is a mess of variables for month, day, and year,
and combining some date functions together, etc etc. *Seems like a lot
of work for what should be very simple.
and what do you think we have to do when we want the date in french ?
* dd/mm/yyyy
var D = new Date();
D.setMonth(D.getMonth()-1)
alert( D.getDate()+''/''+(+D.getMonth()+1)+''/''+D.getFullYear() );
* --19/8/2008
--
smThats fine if all I want is a date, but to be able to subtract 30 days
from any given date introduces a huge mess of logic that needs to be
coded.
I decided to just find an open source date library that had decent
parsing functions for my purpose.
Thanks for the post.
rhaazy <rh****@gmail.comwrites:
On Sep 19, 3:04?*pm, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Thats fine if all I want is a date, but to be able to subtract 30 days
from any given date introduces a huge mess of logic that needs to be
coded.That''s because dates - and times - are VERY messy. A library able to
manipulate dates that is complete enough to be /globally/ useful would
be very large. See for example the amount of stuff in the perl DateTime
project:
http://datetime.perl.org/?Modules
I decided to just find an open source date library that had decent
parsing functions for my purpose.If you can find a decent library, that''s probably the best way to handle
this problem.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
这篇关于Javascript和使用日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!