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












179














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.










share|improve this question
























  • Use Split method to separate the strings
    – AmGates
    Feb 28 '13 at 8:28
















179














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.










share|improve this question
























  • Use Split method to separate the strings
    – AmGates
    Feb 28 '13 at 8:28














179












179








179


20





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.










share|improve this question















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.







javascript date momentjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 8:11









Pang

6,8921563101




6,8921563101










asked Feb 28 '13 at 8:25









ObsivusObsivus

3,388103990




3,388103990












  • Use Split method to separate the strings
    – AmGates
    Feb 28 '13 at 8:28


















  • Use Split method to separate the strings
    – AmGates
    Feb 28 '13 at 8:28
















Use Split method to separate the strings
– AmGates
Feb 28 '13 at 8:28




Use Split method to separate the strings
– AmGates
Feb 28 '13 at 8:28












10 Answers
10






active

oldest

votes


















455














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:



.startOf('day')


Ref: http://momentjs.com/docs/#/manipulating/start-of/






share|improve this answer



















  • 66




    Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
    – colllin
    Nov 6 '13 at 5:37






  • 6




    This should definetly be the accepted answer
    – Luca Steeb
    Apr 23 '15 at 20:03






  • 19




    Also be careful that this function actually mutates the original object
    – Dirk Boer
    Jul 8 '15 at 16:36








  • 4




    .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
    – Sudarshan_SMD
    Dec 13 '16 at 7:18






  • 2




    To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
    – Pang
    May 23 '17 at 8:06



















29














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





share|improve this answer































    12














    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',
    L : 'MM/DD/YYYY',
    LL : 'MMMM D, YYYY',
    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').






    share|improve this answer





























      6














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





      share|improve this answer































        3














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



        var dateTime = moment();

        var dateValue = moment({
        year: dateTime.year(),
        month: dateTime.month(),
        day: dateTime.date()
        });


        See: http://momentjs.com/docs/#/parsing/object/.






        share|improve this answer























        • Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
          – philfreo
          Oct 26 '16 at 18:44










        • 'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
          – oldwizard
          May 17 '17 at 7:13



















        2














        You can also use this format:



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






        share|improve this answer





























          2














          You can use this constructor



          moment({h:0, m:0, s:0, ms:0})


          http://momentjs.com/docs/#/parsing/object/






          console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

          console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

          <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>








          share|improve this answer























          • Add some ore description here
            – Billa
            Aug 23 '18 at 12:45



















          1














          Try this:



          moment.format().split("T")[0]





          share|improve this answer























          • Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
            – Tom
            Nov 20 '17 at 7:49



















          1














          Whenever I use the moment.js library I specify the desired format this way:



          moment(<your Date goes here>).format("DD-MMM-YYYY")


          or



          moment(<your Date goes here>).format("DD/MMM/YYYY")


          ... etc I hope you get the idea



          Inside the format function, you put the desired format. The example above will get rid of all unwanted elements from the date such as minutes and seconds






          share|improve this answer





















          • This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
            – AJ Richardson
            Apr 2 '18 at 21:46



















          0














          For people like me want the long date format (LLLL) but without the time of day, there's a GitHub issue for that: https://github.com/moment/moment/issues/2505. For now, there's a workaround:



          var localeData = moment.localeData( moment.locale() ),
          llll = localeData.longDateFormat( 'llll' ),
          lll = localeData.longDateFormat( 'lll' ),
          ll = localeData.longDateFormat( 'll' ),
          longDateFormat = llll.replace( lll.replace( ll, '' ), '' );
          var formattedDate = myMoment.format(longDateFormat);





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15130735%2fhow-can-i-remove-time-from-date-with-moment-js%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            10 Answers
            10






            active

            oldest

            votes








            10 Answers
            10






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            455














            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:



            .startOf('day')


            Ref: http://momentjs.com/docs/#/manipulating/start-of/






            share|improve this answer



















            • 66




              Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
              – colllin
              Nov 6 '13 at 5:37






            • 6




              This should definetly be the accepted answer
              – Luca Steeb
              Apr 23 '15 at 20:03






            • 19




              Also be careful that this function actually mutates the original object
              – Dirk Boer
              Jul 8 '15 at 16:36








            • 4




              .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
              – Sudarshan_SMD
              Dec 13 '16 at 7:18






            • 2




              To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
              – Pang
              May 23 '17 at 8:06
















            455














            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:



            .startOf('day')


            Ref: http://momentjs.com/docs/#/manipulating/start-of/






            share|improve this answer



















            • 66




              Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
              – colllin
              Nov 6 '13 at 5:37






            • 6




              This should definetly be the accepted answer
              – Luca Steeb
              Apr 23 '15 at 20:03






            • 19




              Also be careful that this function actually mutates the original object
              – Dirk Boer
              Jul 8 '15 at 16:36








            • 4




              .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
              – Sudarshan_SMD
              Dec 13 '16 at 7:18






            • 2




              To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
              – Pang
              May 23 '17 at 8:06














            455












            455








            455






            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:



            .startOf('day')


            Ref: http://momentjs.com/docs/#/manipulating/start-of/






            share|improve this answer














            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:



            .startOf('day')


            Ref: http://momentjs.com/docs/#/manipulating/start-of/







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 26 '18 at 16:18









            trojek

            676730




            676730










            answered Oct 31 '13 at 6:03









            Graham CharlesGraham Charles

            5,52132035




            5,52132035








            • 66




              Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
              – colllin
              Nov 6 '13 at 5:37






            • 6




              This should definetly be the accepted answer
              – Luca Steeb
              Apr 23 '15 at 20:03






            • 19




              Also be careful that this function actually mutates the original object
              – Dirk Boer
              Jul 8 '15 at 16:36








            • 4




              .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
              – Sudarshan_SMD
              Dec 13 '16 at 7:18






            • 2




              To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
              – Pang
              May 23 '17 at 8:06














            • 66




              Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
              – colllin
              Nov 6 '13 at 5:37






            • 6




              This should definetly be the accepted answer
              – Luca Steeb
              Apr 23 '15 at 20:03






            • 19




              Also be careful that this function actually mutates the original object
              – Dirk Boer
              Jul 8 '15 at 16:36








            • 4




              .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
              – Sudarshan_SMD
              Dec 13 '16 at 7:18






            • 2




              To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
              – Pang
              May 23 '17 at 8:06








            66




            66




            Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
            – colllin
            Nov 6 '13 at 5:37




            Be careful with this if you're going between timezones (or if you're not paying attention to timezones). I had an issue where my UTC date was getting converted to local time, then applying startOf('day'), which was then the start of the previous day. Fixed with moment(moment.utc('2013-10-29T00:00:00+00:00').startOf('day').format('LL')).startOf('day').toDate()
            – colllin
            Nov 6 '13 at 5:37




            6




            6




            This should definetly be the accepted answer
            – Luca Steeb
            Apr 23 '15 at 20:03




            This should definetly be the accepted answer
            – Luca Steeb
            Apr 23 '15 at 20:03




            19




            19




            Also be careful that this function actually mutates the original object
            – Dirk Boer
            Jul 8 '15 at 16:36






            Also be careful that this function actually mutates the original object
            – Dirk Boer
            Jul 8 '15 at 16:36






            4




            4




            .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
            – Sudarshan_SMD
            Dec 13 '16 at 7:18




            .startOf('day') does not removes the time part per se, it just sets the time to 00:00:00. So, yes, as commented by 'collin', you have to be careful when saving date. Better alternative is using format('LL'), as have been answered in this thread.
            – Sudarshan_SMD
            Dec 13 '16 at 7:18




            2




            2




            To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
            – Pang
            May 23 '17 at 8:06




            To avoid mutating the original object, use someMoment.clone().startOf('day') or moment(someMoment).startOf('day').
            – Pang
            May 23 '17 at 8:06













            29














            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





            share|improve this answer




























              29














              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





              share|improve this answer


























                29












                29








                29






                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





                share|improve this answer














                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






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 21 '18 at 16:53

























                answered Apr 30 '16 at 0:52









                Joshua PinterJoshua Pinter

                24k8138165




                24k8138165























                    12














                    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',
                    L : 'MM/DD/YYYY',
                    LL : 'MMMM D, YYYY',
                    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').






                    share|improve this answer


























                      12














                      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',
                      L : 'MM/DD/YYYY',
                      LL : 'MMMM D, YYYY',
                      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').






                      share|improve this answer
























                        12












                        12








                        12






                        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',
                        L : 'MM/DD/YYYY',
                        LL : 'MMMM D, YYYY',
                        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').






                        share|improve this answer












                        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',
                        L : 'MM/DD/YYYY',
                        LL : 'MMMM D, YYYY',
                        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').







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 1 '17 at 17:07









                        Sahil JainSahil Jain

                        7061614




                        7061614























                            6














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





                            share|improve this answer




























                              6














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





                              share|improve this answer


























                                6












                                6








                                6






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





                                share|improve this answer














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






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited May 23 '17 at 8:13









                                Pang

                                6,8921563101




                                6,8921563101










                                answered Feb 28 '13 at 8:31









                                AmGatesAmGates

                                1,6781326




                                1,6781326























                                    3














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



                                    var dateTime = moment();

                                    var dateValue = moment({
                                    year: dateTime.year(),
                                    month: dateTime.month(),
                                    day: dateTime.date()
                                    });


                                    See: http://momentjs.com/docs/#/parsing/object/.






                                    share|improve this answer























                                    • Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                      – philfreo
                                      Oct 26 '16 at 18:44










                                    • 'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                      – oldwizard
                                      May 17 '17 at 7:13
















                                    3














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



                                    var dateTime = moment();

                                    var dateValue = moment({
                                    year: dateTime.year(),
                                    month: dateTime.month(),
                                    day: dateTime.date()
                                    });


                                    See: http://momentjs.com/docs/#/parsing/object/.






                                    share|improve this answer























                                    • Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                      – philfreo
                                      Oct 26 '16 at 18:44










                                    • 'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                      – oldwizard
                                      May 17 '17 at 7:13














                                    3












                                    3








                                    3






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



                                    var dateTime = moment();

                                    var dateValue = moment({
                                    year: dateTime.year(),
                                    month: dateTime.month(),
                                    day: dateTime.date()
                                    });


                                    See: http://momentjs.com/docs/#/parsing/object/.






                                    share|improve this answer














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



                                    var dateTime = moment();

                                    var dateValue = moment({
                                    year: dateTime.year(),
                                    month: dateTime.month(),
                                    day: dateTime.date()
                                    });


                                    See: http://momentjs.com/docs/#/parsing/object/.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Feb 2 '18 at 17:59









                                    FlavorScape

                                    4,99665493




                                    4,99665493










                                    answered Sep 10 '15 at 16:52









                                    Torben Rahbek KochTorben Rahbek Koch

                                    582314




                                    582314












                                    • Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                      – philfreo
                                      Oct 26 '16 at 18:44










                                    • 'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                      – oldwizard
                                      May 17 '17 at 7:13


















                                    • Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                      – philfreo
                                      Oct 26 '16 at 18:44










                                    • 'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                      – oldwizard
                                      May 17 '17 at 7:13
















                                    Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                    – philfreo
                                    Oct 26 '16 at 18:44




                                    Wouldn't it be date: dateTime.date() instead of day: dateTime.date()?
                                    – philfreo
                                    Oct 26 '16 at 18:44












                                    'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                    – oldwizard
                                    May 17 '17 at 7:13




                                    'day and date key both mean day-of-the-month.' from the docs. day works pre version 2.8.4.
                                    – oldwizard
                                    May 17 '17 at 7:13











                                    2














                                    You can also use this format:



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






                                    share|improve this answer


























                                      2














                                      You can also use this format:



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






                                      share|improve this answer
























                                        2












                                        2








                                        2






                                        You can also use this format:



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






                                        share|improve this answer












                                        You can also use this format:



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







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jan 4 '17 at 7:54









                                        Hashmita RautHashmita Raut

                                        416




                                        416























                                            2














                                            You can use this constructor



                                            moment({h:0, m:0, s:0, ms:0})


                                            http://momentjs.com/docs/#/parsing/object/






                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>








                                            share|improve this answer























                                            • Add some ore description here
                                              – Billa
                                              Aug 23 '18 at 12:45
















                                            2














                                            You can use this constructor



                                            moment({h:0, m:0, s:0, ms:0})


                                            http://momentjs.com/docs/#/parsing/object/






                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>








                                            share|improve this answer























                                            • Add some ore description here
                                              – Billa
                                              Aug 23 '18 at 12:45














                                            2












                                            2








                                            2






                                            You can use this constructor



                                            moment({h:0, m:0, s:0, ms:0})


                                            http://momentjs.com/docs/#/parsing/object/






                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>








                                            share|improve this answer














                                            You can use this constructor



                                            moment({h:0, m:0, s:0, ms:0})


                                            http://momentjs.com/docs/#/parsing/object/






                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>








                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>





                                            console.log( moment().format('YYYY-MM-DD HH:mm:ss') )

                                            console.log( moment({h:0, m:0, s:0, ms:0}).format('YYYY-MM-DD HH:mm:ss') )

                                            <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>






                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Nov 21 '18 at 22:34

























                                            answered Aug 23 '18 at 12:29









                                            EquaProEquaPro

                                            2044




                                            2044












                                            • Add some ore description here
                                              – Billa
                                              Aug 23 '18 at 12:45


















                                            • Add some ore description here
                                              – Billa
                                              Aug 23 '18 at 12:45
















                                            Add some ore description here
                                            – Billa
                                            Aug 23 '18 at 12:45




                                            Add some ore description here
                                            – Billa
                                            Aug 23 '18 at 12:45











                                            1














                                            Try this:



                                            moment.format().split("T")[0]





                                            share|improve this answer























                                            • Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                              – Tom
                                              Nov 20 '17 at 7:49
















                                            1














                                            Try this:



                                            moment.format().split("T")[0]





                                            share|improve this answer























                                            • Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                              – Tom
                                              Nov 20 '17 at 7:49














                                            1












                                            1








                                            1






                                            Try this:



                                            moment.format().split("T")[0]





                                            share|improve this answer














                                            Try this:



                                            moment.format().split("T")[0]






                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Aug 28 '17 at 23:19









                                            Moe A

                                            3,75371227




                                            3,75371227










                                            answered Aug 28 '17 at 22:59









                                            Keith BlanchardKeith Blanchard

                                            111




                                            111












                                            • Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                              – Tom
                                              Nov 20 '17 at 7:49


















                                            • Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                              – Tom
                                              Nov 20 '17 at 7:49
















                                            Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                            – Tom
                                            Nov 20 '17 at 7:49




                                            Watch out with this method, as 1993-06-07T22:00:00.000Z will result as 1993-06-07 whereas it is the start of the day of 1993-06-08
                                            – Tom
                                            Nov 20 '17 at 7:49











                                            1














                                            Whenever I use the moment.js library I specify the desired format this way:



                                            moment(<your Date goes here>).format("DD-MMM-YYYY")


                                            or



                                            moment(<your Date goes here>).format("DD/MMM/YYYY")


                                            ... etc I hope you get the idea



                                            Inside the format function, you put the desired format. The example above will get rid of all unwanted elements from the date such as minutes and seconds






                                            share|improve this answer





















                                            • This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                              – AJ Richardson
                                              Apr 2 '18 at 21:46
















                                            1














                                            Whenever I use the moment.js library I specify the desired format this way:



                                            moment(<your Date goes here>).format("DD-MMM-YYYY")


                                            or



                                            moment(<your Date goes here>).format("DD/MMM/YYYY")


                                            ... etc I hope you get the idea



                                            Inside the format function, you put the desired format. The example above will get rid of all unwanted elements from the date such as minutes and seconds






                                            share|improve this answer





















                                            • This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                              – AJ Richardson
                                              Apr 2 '18 at 21:46














                                            1












                                            1








                                            1






                                            Whenever I use the moment.js library I specify the desired format this way:



                                            moment(<your Date goes here>).format("DD-MMM-YYYY")


                                            or



                                            moment(<your Date goes here>).format("DD/MMM/YYYY")


                                            ... etc I hope you get the idea



                                            Inside the format function, you put the desired format. The example above will get rid of all unwanted elements from the date such as minutes and seconds






                                            share|improve this answer












                                            Whenever I use the moment.js library I specify the desired format this way:



                                            moment(<your Date goes here>).format("DD-MMM-YYYY")


                                            or



                                            moment(<your Date goes here>).format("DD/MMM/YYYY")


                                            ... etc I hope you get the idea



                                            Inside the format function, you put the desired format. The example above will get rid of all unwanted elements from the date such as minutes and seconds







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Oct 16 '17 at 9:42









                                            Adrian GrzywaczewskiAdrian Grzywaczewski

                                            3551314




                                            3551314












                                            • This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                              – AJ Richardson
                                              Apr 2 '18 at 21:46


















                                            • This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                              – AJ Richardson
                                              Apr 2 '18 at 21:46
















                                            This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                            – AJ Richardson
                                            Apr 2 '18 at 21:46




                                            This is not a good idea if you ever want to display your content in different locales. If you want to display dates in the correct format for the user's locale, you need to use one of the preset date formats (L, LL, etc.)
                                            – AJ Richardson
                                            Apr 2 '18 at 21:46











                                            0














                                            For people like me want the long date format (LLLL) but without the time of day, there's a GitHub issue for that: https://github.com/moment/moment/issues/2505. For now, there's a workaround:



                                            var localeData = moment.localeData( moment.locale() ),
                                            llll = localeData.longDateFormat( 'llll' ),
                                            lll = localeData.longDateFormat( 'lll' ),
                                            ll = localeData.longDateFormat( 'll' ),
                                            longDateFormat = llll.replace( lll.replace( ll, '' ), '' );
                                            var formattedDate = myMoment.format(longDateFormat);





                                            share|improve this answer


























                                              0














                                              For people like me want the long date format (LLLL) but without the time of day, there's a GitHub issue for that: https://github.com/moment/moment/issues/2505. For now, there's a workaround:



                                              var localeData = moment.localeData( moment.locale() ),
                                              llll = localeData.longDateFormat( 'llll' ),
                                              lll = localeData.longDateFormat( 'lll' ),
                                              ll = localeData.longDateFormat( 'll' ),
                                              longDateFormat = llll.replace( lll.replace( ll, '' ), '' );
                                              var formattedDate = myMoment.format(longDateFormat);





                                              share|improve this answer
























                                                0












                                                0








                                                0






                                                For people like me want the long date format (LLLL) but without the time of day, there's a GitHub issue for that: https://github.com/moment/moment/issues/2505. For now, there's a workaround:



                                                var localeData = moment.localeData( moment.locale() ),
                                                llll = localeData.longDateFormat( 'llll' ),
                                                lll = localeData.longDateFormat( 'lll' ),
                                                ll = localeData.longDateFormat( 'll' ),
                                                longDateFormat = llll.replace( lll.replace( ll, '' ), '' );
                                                var formattedDate = myMoment.format(longDateFormat);





                                                share|improve this answer












                                                For people like me want the long date format (LLLL) but without the time of day, there's a GitHub issue for that: https://github.com/moment/moment/issues/2505. For now, there's a workaround:



                                                var localeData = moment.localeData( moment.locale() ),
                                                llll = localeData.longDateFormat( 'llll' ),
                                                lll = localeData.longDateFormat( 'lll' ),
                                                ll = localeData.longDateFormat( 'll' ),
                                                longDateFormat = llll.replace( lll.replace( ll, '' ), '' );
                                                var formattedDate = myMoment.format(longDateFormat);






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Apr 2 '18 at 21:58









                                                AJ RichardsonAJ Richardson

                                                4,1372948




                                                4,1372948






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Stack Overflow!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15130735%2fhow-can-i-remove-time-from-date-with-moment-js%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    404 Error Contact Form 7 ajax form submitting

                                                    How to know if a Active Directory user can login interactively

                                                    Refactoring coordinates for Minecraft Pi buildings written in Python