How can I remove time from date with Moment.js?

How can I remove time from date with Moment.js?

formatCalendarDate = function (dateTime) {
return moment.utc(dateTime).format(‘LLL’);

It displays: “28 februari 2013 09:24”
But I would like to remove the time at the end. How can I do that?
I’m using Moment.js.


Solution 1:

Sorry to jump in so late, but if you want to remove the time portion of a moment() rather than formatting it, then the code is:



Solution 2:

Use format('LL')

Depending on what you’re trying to do with it, format('LL') could do the trick. It produces something like this:

Moment().format('LL'); // => April 29, 2016

Solution 3:

The correct way would be to specify the input as per your requirement which will give you more flexibility.

The present definition includes the following

LTS : 'h:mm:ss A',
LT : 'h:mm A',
LLL : 'MMMM D, YYYY h:mm A',
LLLL : 'dddd, MMMM D, YYYY h:mm A'

You can use any of these or change the input passed into moment().format().
For example, for your case you can pass moment.utc(dateTime).format('MMMM D, YYYY').

Solution 4:

formatCalendarDate = function (dateTime) {
    return moment.utc(dateTime).format('LL')

Solution 5:

With newer versions of moment.js you can also do this:

var dateTime = moment();

var dateValue = moment({
    year: dateTime.year(),
    month: dateTime.month(),


Related:  Loop through properties in JavaScript object with Lodash

Solution 6:

You can also use this format:

moment().format('ddd, ll'); // Wed, Jan 4, 2017