mirror of
https://github.com/dg/dibi.git
synced 2025-08-09 15:47:23 +02:00
- supported UNIX timestamp in datetime column
This commit is contained in:
@@ -527,10 +527,10 @@ class dibi
|
|||||||
{
|
{
|
||||||
if ($time === NULL) {
|
if ($time === NULL) {
|
||||||
$time = time(); // current time
|
$time = time(); // current time
|
||||||
} elseif (is_string($time)) {
|
} elseif (is_numeric($time)) {
|
||||||
$time = strtotime($time); // try convert to timestamp
|
$time = (int) $time; // timestamp
|
||||||
} else {
|
} else {
|
||||||
$time = (int) $time;
|
$time = strtotime($time); // try convert to timestamp
|
||||||
}
|
}
|
||||||
return new DibiVariable($time, dibi::FIELD_DATETIME);
|
return new DibiVariable($time, dibi::FIELD_DATETIME);
|
||||||
}
|
}
|
||||||
|
@@ -503,7 +503,7 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
|
|
||||||
case dibi::FIELD_DATE:
|
case dibi::FIELD_DATE:
|
||||||
case dibi::FIELD_DATETIME:
|
case dibi::FIELD_DATETIME:
|
||||||
$value = strtotime($value);
|
$value = is_numeric($value) ? (int) $value : strtotime($value);
|
||||||
return $format === NULL ? $value : date($format, $value);
|
return $format === NULL ? $value : date($format, $value);
|
||||||
|
|
||||||
case dibi::FIELD_BOOL:
|
case dibi::FIELD_BOOL:
|
||||||
|
@@ -307,7 +307,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
|
|
||||||
case 'd': // date
|
case 'd': // date
|
||||||
case 't': // datetime
|
case 't': // datetime
|
||||||
return $this->driver->escape(is_string($value) ? strtotime($value) : $value, $modifier);
|
return $this->driver->escape(is_numeric($value) ? (int) $value : strtotime($value), $modifier);
|
||||||
|
|
||||||
case 'by':
|
case 'by':
|
||||||
case 'n': // identifier name
|
case 'n': // identifier name
|
||||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user