jQuery change date from format to another one -
i have input text id cldrfrom
it has date this: 04/17/2014 in other words mm/dd/yyyy
i want change format 17-04-2014 in other words dd-mm-yyyy
i want in jquery.
what have tried
var currentdate = $(#cldrfrom").val(); val = val.replace("/", "-"); so replaced / - still need make day first not month. how please?
edit
to take date using datepicker library. call this:
$("#cldrfrom, #cldrto").datepicker(); is there anyway directly make library prints dates in format dd-mm-yyyy ?
just split , join in order want
var currentdate = $("#cldrfrom").val(); var datearr = currentdate.split('/'); var val = datearr[1] + '-' + datearr[0] + '-' + datearr[2];
Comments
Post a Comment