Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return MySQL timestamp on insert

When I perform an insert statement to a MySQL database in PHP, is there a way to return the auto-generated timestamp or do I need a separate call to the database to retrieve the data?

Edit: I forgot that MySQL doesn't use epoch dates. I decided to just use an autoincrementing integer and a stored procedure.

like image 805
spuy767 Avatar asked Aug 12 '26 05:08

spuy767


1 Answers

You need to make a separate request to get that information. You can only get the last insert ID of auto incremented tables when doing an INSERT.

like image 125
John Conde Avatar answered Aug 14 '26 18:08

John Conde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!