How can I format the date using jQuery. I am using below code but getting error:
$("#txtDate").val($.format.date(new Date(), 'dd M yy'));
Please suggest a solution.
How can I format the date using jQuery. I am using below code but getting error:
$("#txtDate").val($.format.date(new Date(), 'dd M yy'));
Please suggest a solution.
ThulasiRam, I prefer your suggestion. It works well for me in a slightly different syntax/context:
If you decide to utilize datepicker from JQuery UI, make sure you use proper references in your document's < head > section:
Take a look here:
https://github.com/mbitto/jquery.i18Now
This jQuery plugin helps you to format and translate date and time according to your preference.
add jquery ui plugin in your page.
Though this question was asked a few years ago, a jQuery plugin isn't required anymore provided the date value in question is a string with format
mm/dd/yyyy
(like when using a date-picker);Simply we can format the date like,
Where "date" is a date in any format.
jQuery dateFormat is a separate plugin. You need to load that explicitly using a
<script>
tag.