javascript - Convert date in UK format and Django format to real date -
i trying convert booking.date
, in following format 01/06/2016
format 'eeee, mmmm d, y' (wednesday, june, 1, 2016)
. i've tried following angularjs filter date doesn't seem working. suggestions?
<p style="small">{{ booking.date | date:'fulldate' }}<br>{{ booking.time }}</p>
i have date in format: 2016-05-31t19:18:24z
elsewhere, there approach can take well?
you should not use date constructor or date.parse parse strings (they equivalent parsing). manually parse strings, library can (there many chose from) if have 1 format simple function sufficient.
to parse string in d/m/y format (which used, it's not peculiar uk in way m/d/y usa) , validate values, use function like:
/* parse date string in d/m/y format ** @param {string} s - date string ** @returns {date} if date invalid, returns invalid date */ function parsedmy(s) { var b = (''+s).split(/\d/); var d = new date(b[2], --b[1], b[0]); return d && d.getmonth() == b[1]? d : new date(nan); } document.write(parsedmy('01/05/2016'));