Get First Day and Last Day of Month



i am triyng to get first and last day of a month

I have seen this example but not working for me…

What i am doing.

It gives me this.

What i am missing?

Thanks in Advance!


does it work like this?

this.date_inicial = new Date();

Otherwise you could consider using momentjs

And there, didn’t tried but, you could find an example about how to find first and last day of the month:


Your code doesn´t work.

Using Moment JS i get the same start date??

Thanks in Advance!


That code works like a charm sorry:

let date_inicial:Date = new Date();

console.log('---> ' + date_inicial);
console.log('---> ' + date_inicial.toDateString());
console.log('---> ' + date_inicial.toISOString());

Give back

---> Sat Oct 01 2016 13:31:00 GMT+0200 (CEST)
---> Sat Oct 01 2016
---> 2016-10-01T11:33:31.000Z


Thanks! It works!

Do you have the code for last day of month?

I think that because leap year i am getting 30/09 for first day of October…


Didn’t tried but maybe

 let next_month:Date = new Date();
 next_month.setMonth(next_month.getMonth() + 1);
 let data_final:Date = new Date(next_month - 1);

…but as I said didn’t tried