| ADOdb Library for PHP Manual | ||
|---|---|---|
| Prev | OffsetDate | Next |
Allows you to calculate future and past dates based on $basedate in a portable fashion. If $basedate is not defined, then the current date (at 12 midnight) is used. Returns the SQL string that performs the calculation when passed to Execute().
For example, in Oracle, to find the date and time that is 2.5 days from today, you can use:
#
get date one week from now
$fld =
$conn->OffsetDate(7);
// returns "(trunc(sysdate)+7")
# get date and time that is 60 hours from current date
and time
$fld =
$conn->OffsetDate(2.5,
$conn->sysTimeStamp); //
returns "(sysdate+2.5)"
$conn->Execute("UPDATE
TABLE SET dodate=$fld WHERE ID=$id");
This function is available for mysql, mssql, oracle, oci8 and postgresql drivers since 2.13. It might work with other drivers provided they allow performing numeric day arithmetic on dates.
| Prev | Home | Next |
| UnixTimeStamp | Up | SQLDate |