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:

https://momentjs.com/

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

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -