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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -