Here's how you can get the date for the last day of this week using TypeScript:
index.ts284 chars8 lines
In this code, we create a moment object representing the current date and time using the moment()
function. We then use the endOf()
function to get the last millisecond of the current week, and store that moment in the endOfWeek
variable. Finally, we format that moment as a string using the format()
function and the YYYY-MM-DD
format string, and store the result in the lastDayOfWeek
variable. We then log that variable to the console, which will output the last day of the current week in the specified format.
gistlibby LogSnag