# man > Date::Manip::Obj

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

## Quick Reference

- `new CLASS $obj` — create new object of given class, sharing config
- `$obj->new($string, @opts)` — create new object from existing object
- `$obj->new_config($string, \@opts)` — create new object with independent config
- `$obj->new_date()` — shortcut for creating a `Date::Manip::Date` object
- `$obj->base()` — get associated `Date::Manip::Base` object
- `$obj->config($var, $val)` — set configuration
- `$obj->err()` — get error message from last failed operation
- `$obj->version()` — return Date::Manip version

## Name

Date::Manip::Obj - Base class for Date::Manip objects

## Synopsis

Class used as base for `Date::Manip::Base`, `Date::Manip::TZ`, `Date::Manip::Date`, `Date::Manip::Delta`, `Date::Manip::Recur`. Not intended to be called directly.

## Methods

### Creating Objects

- `new CLASS ($obj, $string, @parse_opts, \@opts)` — class method to create a new object. If `$obj` is given, shares config; `\@opts` applies new config. `$string` and `@parse_opts` only valid for `Date`, `Delta`, `Recur`.
- `$obj->new($string, @parse_opts, \@opts)` — instance method, same as above. New object shares base/tz from `$obj`.
- `$obj->new_config($string, \@opts)` — creates new object with new `Base` (and possibly `TZ`) object. Config starts identical to original.
- `$obj->new_date()`, `$obj->new_delta()`, `$obj->new_recur()` — shortcuts for creating a `Date`, `Delta`, or `Recur` object from `$obj`. Accept same optional arguments as `new`.

### Accessing Sub‑objects

- `$obj->base()` — returns the associated `Date::Manip::Base` object. If `$obj` is a `Base` object, returns nothing.
- `$obj->tz()` — returns the associated `Date::Manip::TZ` object. If `$obj` is a `TZ` or `Base` object, returns nothing.

### Configuration

- `$obj->config($var1, $val1, $var2, $val2, ...)` — set configuration variables. See [Date::Manip::Config](https://metacpan.org/pod/Date::Manip::Config).
- `@var = $obj->get_config()` — returns list of all config variable names (lowercase).
- `$val = $obj->get_config($var)` — returns value of a single config variable.
- `@val = $obj->get_config($var1, $var2, ...)` — returns values for multiple variables.

### Error Handling

- `$err = $obj->err()` — returns full error message from last failed operation. `$obj->err(1)` clears the error code.

### Type Detection

- `$obj->is_date()` — returns 1 if object is a `Date::Manip::Date`, 0 otherwise.
- `$obj->is_delta()` — returns 1 if object is a `Date::Manip::Delta`, 0 otherwise.
- `$obj->is_recur()` — returns 1 if object is a `Date::Manip::Recur`, 0 otherwise.

### Version

- `$vers = $obj->version($flag)` — returns Date::Manip version. If `$flag` is true and `$obj` is not a `Base` object, also returns timezone information.

## Examples

perl
use Date::Manip::Date;

# Create a new Date object (no string)
$date = Date::Manip::Date->new();

# Create with a parsed string and custom config
$date = Date::Manip::Date->new("2020-01-01", \@opts);

# Clone an existing object (shares config)
$date2 = $date1->new();

# Create with independent config
$date2 = $date1->new_config("2020-06-15", \@opts);

# Get base object and set configuration
$base = $date->base();
$base->config("DateFormat", "US");

# Check for errors after parsing
$date->parse("invalid date");
if ($date->err()) {
    warn "Error: " . $date->err();
}
## See Also

- [Date::Manip](https://metacpan.org/pod/Date::Manip) — main module
- [Date::Manip::Objects](https://metacpan.org/pod/Date::Manip::Objects) — object management
- [Date::Manip::Config](https://metacpan.org/pod/Date::Manip::Config) — configuration variables
- [Date::Manip::Problems](https://metacpan.org/pod/Date::Manip::Problems) — bug reporting
- [Date::Manip::Base](https://metacpan.org/pod/Date::Manip::Base)
- [Date::Manip::TZ](https://metacpan.org/pod/Date::Manip::TZ)
- [Date::Manip::Date](https://metacpan.org/pod/Date::Manip::Date)
- [Date::Manip::Delta](https://metacpan.org/pod/Date::Manip::Delta)
- [Date::Manip::Recur](https://metacpan.org/pod/Date::Manip::Recur)