-2

I have got data as e.g. 2018-11-06T15:25:00 in the format. I want the output as 06 Jun 2018, 03:25 p.m. Is there any way through which I can directly convert it?

Mrugesh
  • 4,381
  • 8
  • 42
  • 84
  • Have you checked any docs., like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString ?? – Asons Jun 26 '18 at 20:47
  • Have a look here (possible duplicate): https://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript – ZiGaelle Jun 26 '18 at 20:47
  • 2
    Possible duplicate of [Where can I find documentation on formatting a date in JavaScript?](https://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript) – Asons Jun 26 '18 at 20:48
  • @LGSon First of all solution that you have suggested is not what I have asked and please look at the format I have given , it does not have `z` in second – Mrugesh Jun 26 '18 at 20:50
  • That dupe link holds all you need (2 pages of answers), you just need to read it, so with the docs. – Asons Jun 26 '18 at 20:53

1 Answers1

2

I highly suggest using momentjs. Just use given format DD MMM YYYY, hh:mm a.

Example code:

const date = '2018-11-06T15:25:00';

console.log(moment(date).format('DD MMM YYYY, hh:mm a'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
loelsonk
  • 3,570
  • 2
  • 16
  • 23
  • @LGSon I didn't see your comment when I start adding my answer. – loelsonk Jun 26 '18 at 21:50
  • Well, I think that users not putting enough effort into their questions shouldn't get an answer, which were more why I commented about it. If the OP would have taken the time to read the docs. they would found their answer – Asons Jun 26 '18 at 21:58