开发者

jQuery: How can I work with dates in this format? mm/yyyy

I'm doing a web application for articles

Articles must be shown by month, 开发者_运维知识库with its published date stored as mm/yyyy

Now:

1- Should I use a DATE type field for storing?

2- Will jQuery UI datePicker be useful for showing mm/yyyy?

3- How could I sort by mm/yyyy?

I guess it will be more complicated if I store date normally and extract the day from date each time I want to do something, right?

Thanks,


I would store the published date as a DateTime value in my database and then do something different for the display. With the DatePicker's you can set the format for how the date should be presented.

$( "MyDate" ).datepicker( { altFormat: 'mm/yyyy' } );

If your articles are always Month and Year and the actual day doesn't matter, you may want to think about usability a bit. It may be better to use Drop Down Lists for the Months and Year...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜