Convert string to date format using javascript -
i have string value , need convert string value following date format using javascript.
var strdate = "2016-11-20";
expected output is: 20-nov-2016
how can change this?
a little workaround following, if have manipulate dates lot, recommend use moment.js library:
var strdate = "2016-11-20"; var utcdate = new date(strdate).toutcstring(); var converteddate= utcdate.substring(utcdate.lastindexof(", ") + 1, utcdate.lastindexof(" 00:")); console.log(converteddate.trim().replace(/\s/g, '-'));
pay attention implementation of method may change depending on platform. here official doc:
the value returned toutcstring() human readable string in utc time zone. format of return value may vary according platform. common return value rfc-1123 formatted date stamp, updated version of rfc-822 date stamps.
Comments
Post a Comment