如何在symfony2中设置创建和更新日期? [英] How to set created and updated date in symfony2?

查看:55
本文介绍了如何在symfony2中设置创建和更新日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个待办事项应用程序,用户可以在其中创建任务。用户可以选择插入标题,截止日期,完成。我希望能够在用户创建任务时自动插入创建和更新的日期。

解决方案

一个更好的解决方案是使用来自gedmo的Doctrine的时间戳扩展:
https:// github .com / Atlantic18 / DoctrineExtensions / blob / master / doc / timestampable.md 。和更新的时间戳。


I am creating a todo app where the user can create tasks.The user has the options of inserting title, due date, completed. I want to be able to insert created and updated date automatically when the user creates the task.

解决方案

A better solution is to use the Timestampable extension for Doctrine from gedmo: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/timestampable.md.

This extension uses lifecyclecallbacks, but it is a cleaner way to set created and updated timestamps.

这篇关于如何在symfony2中设置创建和更新日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆