Answer the question
In order to leave comments, you need to log in
How to convert date format 3:32 AM - 17 Aug 2018 to Aug 17 2018?
There is a json that gives a date value in the form 3:32 AM - 17 Aug 2018. As far as I understand this is a string. Is it possible to somehow just convert it to Aug 17 2018?
console.log(new Date(value)); - gives Invalid date.
I found nothing easier than converting through a custom filter like this
transform(value: string): string {
var timeToDate = value.split(/- /),
date = timeToDate[1].split(/ /),
day = date[0],
month = date[1],
year = date[2],
newDate = month + " " + day + ", " + year;
return newDate;
<span >{{ line.date | stringToDate }}</span>
line.date
Answer the question
In order to leave comments, you need to log in
There is a json that gives a date value in the form 3:32 AM - 17 Aug 2018. As far as I understand this is a string. Is it possible to somehow just convert it to Aug 17 2018?
console.log(new Date(value)); - gives Invalid date.
this.line.date
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question