Gets the day of the year from a Date object.

Use new Date() and Date.prototype.getFullYear() to get the first day of the year as a Date object, subtract it from the provided date and divide with the milliseconds in each day to get the result.
Use Math.floor() to appropriately round the resulting day count to an integer.

继续阅读 30秒学会 JavaScript 片段 – dayOfYear

Results in a string representation of yesterday’s date.

Use new Date() to get the current date, decrement by one using Date.getDate() and set the value to the result using Date.setDate().
Use Date.prototype.toISOString() to return a string in yyyy-mm-dd format.

继续阅读 30秒学会 JavaScript 片段 – yesterday

Results in a string representation of tomorrow’s date.

Use new Date() to get the current date, increment by one using Date.getDate() and set the value to the result using Date.setDate().
Use Date.prototype.toISOString() to return a string in yyyy-mm-dd format.

继续阅读 30秒学会 JavaScript 片段 – tomorrow