I'm using jquery and moment.js for a custom calendar.
I have a date object in a variable myDate
like :
Object { date="2014-12-23 14:00:00", timezone_type=3, timezone="Europe/Paris"}
I want, using moment.js (or not) get the day name of this date, in my example i need to get : tuesday
Ideas ? Thanks
This question is related to
javascript
date
calendar
momentjs
var mydate = "2017-06-28T00:00:00";
var weekDayName = moment(mydate).format('dddd');
console.log(weekDayName);
mydate is the input date. The variable weekDayName get the name of the day. Here the output is
Wednesday
var mydate = "2017-08-30T00:00:00";_x000D_
console.log(moment(mydate).format('dddd'));_x000D_
console.log(moment(mydate).format('ddd'));_x000D_
console.log('Day in number[0,1,2,3,4,5,6]: '+moment(mydate).format('d'));_x000D_
console.log(moment(mydate).format('MMM'));_x000D_
console.log(moment(mydate).format('MMMM'));
_x000D_
<script src="https://momentjs.com/downloads/moment.js"></script>
_x000D_
var mydate = "2017-06-28T00:00:00";
var weekDayName = moment(mydate).format('ddd');
console.log(weekDayName);
Result: Wed
var mydate = "2017-06-28T00:00:00";
var weekDayName = moment(mydate).format('dddd');
console.log(weekDayName);
Result: Wednesday
Source: Stackoverflow.com