Sumith Chalil
Sumith Chalil

Reputation: 358

How to format a date in moment js

How to format 2019-07-29T05:55:00 to 29 Jul 2019 (Mon) in moment js ? What should be the formatdate string ? 'DD MMM YYYY (ddd) is not accepted by moment js

Upvotes: 0

Views: 1376

Answers (3)

Floxx
Floxx

Reputation: 31

I'm not allowed to comment yet, but I when I saw your question I was sure your format was correct.

var now = moment().format('DD MMM YYYY (ddd)');

Tried it out in JS fiddle and it works.

Upvotes: 1

Rahul Tripathi
Rahul Tripathi

Reputation: 172378

var myDate = moment('2019-07-29T05:55:00').format('DD MMM YYYY (ddd)');
result.innerHTML = myDate ;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.js"></script>
<pre id="result"></pre>

Upvotes: 0

Net Solver
Net Solver

Reputation: 127

It should be working fine, the correct syntax: var test = moment().format('DD MMM YYYY (ddd)');

Upvotes: 0

Related Questions