jQuery moment.js get day name from date

jQuery moment.js get day name from date

Asked on December 27, 2018 in Javascript.
Add Comment


  • 3 Answer(s)

    One can define and parse the date string by using moment.js like this,

    var dt = moment(myDate.date, "YYYY-MM-DD HH:mm:ss")
    
    

    The UTC, we have to convert the time zone from the particular point.

    By using this snippet we can get the day of the week.

    dt.format('dddd');
    
    
    Answered on December 27, 2018.
    Add Comment

    Here is the code,
    var mydate = “2017-06-28T00:00:00”;
    var weekDayName = moment(mydate).format(‘dddd’);
    console.log(weekDayName);
    In the above code ‘mydate’ is input . And the variable ‘weekDayName’ gets the name of the day.

    Yields,
    Wednesday.

    var mydate = "2017-06-28T00:00:00";
    var weekDayName = moment(mydate).format('dddd');
    console.log(weekDayName);
    
    <script src="https://momentjs.com/downloads/moment.js"></script>
    
    Answered on December 27, 2018.
    Add Comment

    Try these two types of code,

    var mydate = "2017-06-28T00:00:00";
    var weekDayName = moment(mydate).format('ddd');
    console.log(weekDayName);
    

    It gives,

    Wed

    var mydate = "2017-06-28T00:00:00";
    var weekDayName = moment(mydate).format('dddd');
    console.log(weekDayName);
    

    It gives ,

    Wednesday

    Answered on December 27, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.