Now is a simple helpers for working with time (Carbon).

1.0 2025-05-25 13:23 UTC

This package is auto-updated.

Last update: 2025-05-25 13:25:41 UTC


README

A collection of handy date helper functions built on top of Carbon.

Installation

composer require romanlazko/now

Usage

All functions are automatically available in your PHP application.

Available Functions

Basic Date Functions

// Get current date and time
now();

// Get today's date
today();

// Get tomorrow's date
tomorrow();

// Get yesterday's date
yesterday();

Time Period Functions

// Get start and end of week
startOfWeek();
endOfWeek();

// Get start and end of month
startOfMonth();
endOfMonth();

// Get start and end of year
startOfYear();
endOfYear();

Date Comparison Functions

// Check if date is in the past
isPast('2023-01-01');

// Check if date is in the future
isFuture('2025-01-01');

// Compare dates
isSameDay('2025-05-25', '2025-05-25');
isSameMonth('2025-05-01', '2025-05-31');
isSameYear('2025-01-01', '2025-12-31');

Day Type Functions

// Check if date is a weekend
isWeekend('2025-05-25');

// Check if date is a weekday
isWeekday('2025-05-27');

// Check if date is today/tomorrow/yesterday
isToday('2025-05-25');
isTomorrow('2025-05-26');
isYesterday('2025-05-24');

Date Range Functions

// Check if date is between two dates
isBetween('2025-05-25', '2025-05-01', '2025-05-31');

// Get array of dates between two dates
datesBetween('2025-05-01', '2025-05-05');

// Calculate age from date
ageFromDate('2000-01-01');

Requirements

  • PHP 8.0 or higher
  • Carbon PHP package

License

MIT License