Reputation: 1241
Suppose I gave a value as 4:30 I then split them into something like this ['4' , '30']. I want to use moment to format it into something like this moment("2010-10-20 4:30", "YYYY-MM-DD HH:mm"); // parsed as 4:30 localtime any clues..?
here the date will be todays date.
Upvotes: 0
Views: 163
Reputation: 9034
You can achieve this by
var moment = require('moment')
moment("2010-10-20 04:30").format("YYYY-MM-DD HH:mm"); // will produce '2010-10-20 04:30'
More format examples:
moment().format('MMMM Do YYYY, h:mm:ss a'); // November 9th 2016, 11:47:05 am
moment().format('dddd'); // Wednesday
moment().format("MMM Do YY"); // Nov 9th 16
moment().format('YYYY [escaped] YYYY'); // 2016 escaped 2016
moment().format(); // 2016-11-09T11:47:05+01:00
Upvotes: 1