
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@utilify/date
Advanced tools
The `@utilify/date` package offers essential utilities for working with dates and times in JavaScript and TypeScript. These functions are designed to be intuitive, efficient, and type-safe.
The @utilify/date package offers essential utilities for working with dates and times in JavaScript and TypeScript. These functions are designed to be intuitive, efficient, and type-safe.
To install the Date package, use one of the following commands:
npm install @utilify/date
yarn add @utilify/date
pnpm add @utilify/date
Import the functions into your project:
import { formatDate, isLeapYear } from '@utilify/date';
const formatted = formatDate(new Date(), 'YYYY-MM-DD');
const leapYear = isLeapYear(2024);
console.log(formatted, leapYear);
const { formatDate, isLeapYear } = require('@utilify/date');
const formatted = formatDate(new Date(), 'YYYY-MM-DD');
const leapYear = isLeapYear(2024);
console.log(formatted, leapYear);
function adjustDate(date: Date, amount: number, unit: TimeUnit): Date
Adjusts a date by adding or subtracting a time interval.
function adjustTimezone(date: Date, timezoneOffset: number): Date
Converts a date to a different timezone.
function convertTimeUnit(time: number, from: TimeUnit, to: TimeUnit): number
Converts time units, such as milliseconds to minutes.
function convertDateTo(date: Date, format: DateFormat): string | undefined
Converts a date to another format or representation.
function formatDate(date: Date, format: DateFormat = "DMY", separator: string = "/"): string | undefined
Formats a date into a user-friendly string.
function formatDuration(ms: number, format: string = "hh:mm:ss", autoHour: boolean = true): string
Formats a duration of time into a readable string.
function formatTime(date: Date, format: string = "hh:mm:ss"): string | undefined
Formats the time component of a date.
function isLeapYear(year: number): boolean
Checks if a year is a leap year.
function isValidDate(date: Date): boolean
Validates whether an object or string represents a valid date.
function isValidDateString(date: string): boolean
Validates whether a string follows a recognized date format.
function isWeekday(date: Date): boolean | undefined
Checks if a date is a weekday (Monday to Friday).
function isWeekend(date: Date): boolean | undefined
Checks if a date is a weekend (Saturday or Sunday).
function parseDate(date: string): Date | undefined
Converts a string or number to a Date object.
FAQs
The `@utilify/date` package offers essential utilities for working with dates and times in JavaScript and TypeScript. These functions are designed to be intuitive, efficient, and type-safe.
We found that @utilify/date demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.