mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT SSDatetime->setValue() can now set a timestamp, consistently working the same as Date does
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77120 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a4cf64f105
commit
5322ecc692
@ -12,13 +12,18 @@
|
|||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
class SSDatetime extends Date {
|
class SSDatetime extends Date {
|
||||||
|
|
||||||
function setValue($value) {
|
function setValue($value) {
|
||||||
// Default to NZ date format - strtotime expects a US date
|
// Default to NZ date format - strtotime expects a US date
|
||||||
if(ereg('^([0-9]+)/([0-9]+)/([0-9]+)$', $value, $parts))
|
if(ereg('^([0-9]+)/([0-9]+)/([0-9]+)$', $value, $parts)) {
|
||||||
$value = "$parts[2]/$parts[1]/$parts[3]";
|
$value = "$parts[2]/$parts[1]/$parts[3]";
|
||||||
|
}
|
||||||
|
|
||||||
if($value) $this->value = date('Y-m-d H:i:s', strtotime($value));
|
if(is_numeric($value)) {
|
||||||
else $value = null;
|
$this->value = date('Y-m-d H:i:s', $value);
|
||||||
|
} elseif(is_string($value)) {
|
||||||
|
$this->value = date('Y-m-d H:i:s', strtotime($value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Nice() {
|
function Nice() {
|
||||||
|
Loading…
Reference in New Issue
Block a user