Skip to main content

Check if a date occurs in the current year

JavaScript version

// `date` is a Date object
const isCurrentYear = (date) => date.getUTCFullYear() === new Date().getUTCFullYear();

TypeScript version

const isCurrentYear = (date: Date): boolean => date.getUTCFullYear() === new Date().getUTCFullYear();

Comments