当たり前のような気がするけど、
$ts-node > const today = new Date() > today 2021-02-28T23:04:18.705Z > const lastMonth = new Date(today.getTime()) > lastMonth.setMonth(today.getMonth() -1) > lastMonth 2021-01-31T23:04:18.705Z
setMonth で月の値を指定する際、なんとなく 1/28 になってそうだな、と思っていたのでちょっと驚いたのでした。それにしても node というか JS の伝統的な Date 、なんとも言えないインターフェイスである。(今知ったわけではないけど改めて)