# man > Date::Manip::Base

---
type: CommandReference
command: Date::Manip::Base
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference

- `$dmb = Date::Manip::Base->new()` — create a new base object
- `$dmb->config($var, $val, ...)` — set configuration variables
- `$dmb->calc_date_date($date1, $date2)` — days between two dates
- `$dmb->calc_date_days($date, $n [, $subtract])` — add/subtract days
- `$dmb->calc_date_delta($date, $delta [, $subtract])` — add/subtract delta (years, months, weeks, days, etc.)
- `$dmb->calc_date_time($date, $time [, $subtract])` — add/subtract time (hours, minutes, seconds)
- `$dmb->calc_time_time($time1, $time2 [, $subtract])` — add/subtract two times
- `$dmb->cmp($date1, $date2)` — compare dates (-1, 0, 1)
- `$dmb->day_of_week($date)` — day of week (1=Monday, 7=Sunday)
- `$dmb->day_of_year($ymd)` — day of year (1..366)
- `$dmb->days_in_month($y, $m)` — days in a month
- `$dmb->days_since_1BC($date)` — days since 31 Dec 1BC (for difference)
- `$dmb->leapyear($y)` — 1 if leap year
- `$dmb->nth_day_of_week($y, $n, $dow [, $m])` — nth weekday in year/month
- `$dmb->secs_since_1970($date)` — seconds since 1970-01-01
- `$dmb->split($type, $string, \%opts)` — parse date/time/delta string
- `$dmb->join($type, $obj, \%opts)` — format date/time/delta to string
- `$dmb->week_of_year($date)` — ISO 8601 week number (1-53) and year

## Name

Date::Manip::Base — Base methods for date manipulation

## Synopsis

perl
use Date::Manip::Base;
$dmb = new Date::Manip::Base;
## Description

The `Date::Manip::Base` module provides low-level date/time arithmetic routines. These routines ignore time zones and daylight saving time (treat dates as GMT). No error checking is performed; invalid input yields meaningless results. For error checking, use the higher-level `Date::Manip` routines.

## Methods

### Constructor and Configuration

- `$dmb = Date::Manip::Base->new()` — create new base object. Inherits `err()`, `new()`, `config()` from `Date::Manip::Obj`.
- `$dmb->config($var, $val, ...)` — set configuration variables (see `Date::Manip::Config`).

### Date Arithmetic

- `$time = $dmb->calc_date_date($date1, $date2)` — returns a delta (list of years, months, weeks, days, hours, minutes, seconds) between two dates.
- `$date = $dmb->calc_date_days($date, $n [, $subtract])` — returns date `$n` days later (or earlier if `$n < 0`). If `$subtract` is true, sign is reversed. Also works with `$ymd` (date only).
- `$date = $dmb->calc_date_delta($date, $delta [, $subtract])` — add (or subtract) a delta (list of years, months, weeks, days, hours, minutes, seconds) to a date.
- `$date = $dmb->calc_date_time($date, $time [, $subtract])` — add (or subtract) a time (hours, minutes, seconds) to a date.
- `$time = $dmb->calc_time_time($time1, $time2 [, $subtract])` — add (or subtract if `$subtract` true) two times.

### Date Queries

- `$valid = $dmb->check($date)` — returns 1 if date fields are valid (ignoring time zones).
- `$valid = $dmb->check_time($hms)` — returns 1 if time (00:00:00 to 24:00:00) is valid.
- `$cmp = $dmb->cmp($date1, $date2)` — returns -1, 0, or 1.
- `$day = $dmb->day_of_week($date)` — returns 1 (Monday) to 7 (Sunday).
- `$day = $dmb->day_of_year($ymd)` — returns integer day of year (1..366). With `$date` returns fractional day (e.g., 1.5 = Jan 1 noon). Inverse: `$ymd = $dmb->day_of_year($y, $day)`.
- `$days = $dmb->days_in_month($y, $m)` — returns days in month. If `$m == 0`, returns list of 12 elements.
- `$days = $dmb->days_in_year($y)` — returns 365 or 366.
- `$days = $dmb->days_since_1BC($date)` — returns days since 31 Dec 1BC (projected Gregorian). Inverse: `$ymd = $dmb->days_since_1BC($days)`.
- `$flag = $dmb->leapyear($y)` — returns 1 if leap year.
- `$ymd = $dmb->nth_day_of_week($y, $n, $dow [, $m])` — returns date of `$n`th occurrence of weekday `$dow` (1..7) in year (or month if `$m` given). `$n` ranges 1..53 or -1..-53.
- `$secs = $dmb->secs_since_1970($date)` — returns seconds since 1970-01-01 00:00:00 (negative if earlier). Inverse: `$date = $dmb->secs_since_1970($secs)`.
- `$ymd = $dmb->week1_day1($y)` — first day of ISO 8601 week 1 in given year.
- `$w = $dmb->weeks_in_year($y)` — number of ISO weeks (52 or 53).
- `($y, $w) = $dmb->week_of_year($date)` — returns ISO week number and year. Inverse: `$ymd = $dmb->week_of_year($y, $w)` returns first day of that week.

### Split and Join

- `$obj = $dmb->split($type, $string, \%opts)` — parse string into a list reference. `$type` can be `'date'`, `'hms'`, `'offset'`, `'time'`, `'delta'` (or `'business'`). Options: `'nonorm'` (0/1), `'mode'` (standard/business), `'type'` (exact/semi/approx/estimated).
- `$string = $dmb->join($type, $obj, \%opts)` — format list reference into string.

## See Also

- [Date::Manip](http://localhost/phpMan.php/perldoc/Date%3A%3AManip/markdown) — main module documentation
- [Date::Manip::Obj](http://localhost/phpMan.php/perldoc/Date%3A%3AManip%3A%3AObj/markdown) — base class methods
- [Date::Manip::Config](http://localhost/phpMan.php/perldoc/Date%3A%3AManip%3A%3AConfig/markdown) — configuration variables
- [Date::Manip::Delta](http://localhost/phpMan.php/perldoc/Date%3A%3AManip%3A%3ADelta/markdown) — delta format rules