Enrique
Enrique

Reputation: 1055

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,

Upvotes: 0

Views: 276

Answers (1)

RSolberg
RSolberg

Reputation: 26982

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...

Upvotes: 1

Related Questions