date format jquery with common output format from date -
my date is some time 2014-08-01
and sometime 01-08 -2014
but I need production such as 01-08-2014
regdate.split ("-")
This is not suitable for the above input. To get the normal output date format, I am left by using a client side method 01-08-2014
Try it out:
var day = myDate.getDate (); Var month = myDate.getMonth () + 1; Var year = myDate.getFullYear (); If (day & lt; 10) {days = "0" + day; } If (month & lt; 10) {month = "0" + month; } Var formatted date = day + "-" + month + "-" + year;
This will give you an output date in the format DD-MM-YYYY
regardless of the date the server received.
Comments
Post a Comment