开发者

javascript implementation of java.util.calendar api

开发者 https://www.devze.com 2023-03-05 13:06 出处:网络
Is there a javascri开发者_运维知识库pt equivalent implementation of java.util.Calendar API?It will be quite handy to do date manipulation with it around.Though not exact http://momentjs.com/ is much b

Is there a javascri开发者_运维知识库pt equivalent implementation of java.util.Calendar API? It will be quite handy to do date manipulation with it around.


Though not exact http://momentjs.com/ is much better in many ways ! I would go for this if given a choice.

Formatting dates

moment().format('MMMM Do YYYY, h:mm:ss a');
moment().format('dddd');
moment().format("MMM Do YY");
moment().format('YYYY [escaped] YYYY');
moment().format();

September 23rd 2012, 1:29:09 am
Sunday
Sep 23rd 12
2012 escaped 2012
2012-09-23T01:29:09+01:00

Timeago

moment("20111031", "YYYYMMDD").fromNow();
moment("20120620", "YYYYMMDD").fromNow();
moment().startOf('day').fromNow();
moment().endOf('day').fromNow();
moment().startOf('hour').fromNow();

11 months ago
3 months ago
an hour ago
in a day
28 minutes ago

Calendar Time

moment().subtract('days', 10).calendar();
moment().subtract('days', 6).calendar();
moment().subtract('days', 3).calendar();
moment().subtract('days', 1).calendar();
moment().calendar();
moment().add('days', 1).calendar();
moment().add('days', 3).calendar();
moment().add('days', 10).calendar();

09/12/2012
last Sunday at 12:06 PM
last Wednesday at 12:06 PM
Yesterday at 12:06 PM
Today at 12:06 PM
Tomorrow at 12:06 PM
Tuesday at 12:06 PM

Internationalization

moment().format('L');
moment().format('LL');
moment().format('LLL');
moment().format('LLLL');

09/22/2012
September 22 2012
September 22 2012 12:07 PM
Saturday, September 22 2012 12:07 PM


YUI 2: Calendar, I think is a similar to what you are looking for..

Also a this would get you many answers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号