I have configure moment with my angular2 application, and when i tried to assign the date of this week saturday to a date type variable,
case "weekend":
this.fromDate = moment().startOf('week');
It shows an error saying,
Type 'Moment' is not assignable to type 'Date'. Property 'toDateString' is missing in type 'Moment'
I have imported moment in my component as follows,
import * as moment from 'moment/moment';
startOf
:
Mutates the original moment by setting it to the start of a unit of time
so it returns a moment object. Use toDate()
if you need to convert to JavaScript Date.
case "weekend":
this.fromDate = moment().startOf('week').toDate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With