search

Home  >  Q&A  >  body text

Regarding the issue of turning on automatic timestamps and template output time conversion.

Hello, teachers and classmates.

During development, automatic timestamps were turned on. During template output, it was found that conventional automatic timestamp conversion failed.

Later put it in the database.

'datetime_format' => 'Y-m-d H:i:s', after changing this option to false, the normal conversion in the template still fails.

Please tell me how to output correctly.

善為善為2072 days ago1247

reply all(2)I'll reply

  • 善為

    善為2019-05-20 17:02:48

    Due to the rules of the framework, the timestamp writing function is automatically enabled. You need to get the timestamp through the getter in the model, and then format the time in the getter. Just call this field directly when calling it in the template.

    Use the getter in the model to get it. Format and return.

    QQ截图20190520170000.png


    Directly output in the template

    QQ截图20190520170054.png


    Note: Turn on automatic timestamp writing. Generally, the timestamp written through the model method can take effect normally. When reading, data is also obtained through the model. The time displayed on the front desk can be converted normally.

    33.png

    reply
    0
  • 殘留の回憶

    殘留の回憶2019-05-20 16:55:36

    Write directly in native form, <?php date('Y-m-d H:i:s',time());?>

    reply
    0
  • Cancelreply