duanjiao7440 2013-07-19 03:38
浏览 39

Silverstripe 2.3.1仅将日期字段保存为1970-1-1

When I save an DataObject with a Date field from a form it gets saved as 1970-1-1.

It's a standard

public static $db = array(
  'MyDate' => 'Date'
);

then

$form->saveInto($obj);
$obj->write();

although both stages (saveinto,write) seem to change the value to 1970. I realise this is not much to go on so I guess I'm after suggestions for how to debug it.

it's using the ecommerce and payment modules.

  • 写回答

1条回答 默认 最新

  • duai1683 2013-08-02 03:12
    关注

    The docs (http://api.silverstripe.org/2.4/class-Date.html) state "The field currently supports New Zealand date format (DD/MM/YYYY), or an ISO 8601 formatted date (YYYY-MM-DD)"

    If the date is being saved as epoch default, it is likely that it's being passed in in an incorrect format. This could be due to a locale difference between your server and the date format that the data type expects.

    You'll need to see the format of $obj->MyDate and manipulate it before calling $form->saveInto() so the date is saved in the correct format.

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作