Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    I vote up for this answer because it is the pure PHP solution. Other answers may: 1) need special knowledge onPrePersistSetRegistrationDate which add HasLifecycleCallbacks, PrePersist annotations 2) I want to set a default value needs me to add 3rd library @Gedmo\Timestampable?!! 3) CURRENT_TIMESTAMP is sometimes not good. Ex.: when your script server in China but database server in America. ( of cause, it is not very common, but there are such cases ) Commented Apr 7, 2017 at 7:01
  • @Yarco It depends on a case. When you have a table without a datetime column and then decides to add it - you need a default value to be populated for existing table rows. In this case PHP solution will not work. Commented Jul 16, 2020 at 9:15