Field::getDateReference()

Version 3.8

Reference to value in eDate object

Return Date object that is a reference to fields value. Can be used for editing the value in field.

Return value

Object eDate

Full documentation

Add three days to fields date -value.

$Order->delivery_date->getDateReference()->addDays(3);

Using eDate directly

Methods of eDate object can be called directly via date field object. This is a shorthand for previous example:

$Order->delivery_date->addDays(3);

Get number of days between today and the date in field:

$Order->delivery_date->diffDays('Today');

Loop through all days in dates week:

foreach ( $Order->delivery_date->getDatesInWeek() as $date ){
    $txt .= "Add date: {$date}";
}

Loop through days until given date:

foreach ( $Order->delivery_date->getDatesTo($endDate) ){
    $txt .= "Add date: {$date}";
}

Get dates week/month limits

$Date = $Order>delivery_date->getFirstDateOfWeek();
$Date = $Order->delivery_date->getLastDateOfWeek();
$Date = $Order->delivery_date->getFirstDateOfMonth();
$Date = $Order->delivery_date->getLastDateOfMonth();

For more information, see eDate