javascript - Get start of a given date using momentjs -
i trying start of , end of day. below code.
var m = moment(new date('fri aug 8 2017 11:31:08 gmt+0530 (india standard time)')).startof('day') console.log(m); var n = moment(new date('fri aug 8 2017 11:31:08 gmt+0530 (india standard time)')).endof('day') console.log(n.format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
i tried
moment(new date('fri aug 8 2017 11:31:08 gmt+0530 (india standard time)')).startof('date')
nothing seems work. moment support functionality.
it work latest version of moment. check snippet.
also if want format time in ist
can apply fixed utc offset , format date in desired format.
var st = moment(new date('fri aug 8 2017 11:31:08 gmt+0530 (india standard time)')).startof('day').utcoffset("+05:30").format() console.log(st); var end = moment(new date('fri aug 8 2017 11:31:08 gmt+0530 (india standard time)')).endof('day').utcoffset("+05:30").format() console.log(end);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
Comments
Post a Comment