In Laravel, the Illuminate\Database\Schema\Blueprint
class has two methods that I would like to know concretely the difference between them.
$table->dateTime()
and
$table->timestamp()
Both store a date in the same way visibly. Someone to enlighten me?
So the secret to this is understanding what exactly each does.
The dateTime()
and timestamp()
functions here in Laravel use different table columns.
dateTime()
uses DATETIME as the DB column type. timestamp()
uses TIMESTAMP as the DB column type.
DATETIME
and TIMESTAMP
have a lot of similarities but the difference itself lies outside Laravel and more in MySQL.
Their major difference is the range. For DateTime its up to year 9999
while for timestamp its only up to year 2038
. Other differences include the amount of bytes needed to store each.
I found a nice article that clearly states the similarities and differences of both here http://www.c-sharpcorner.com/article/difference-between-mysql-datetime-and-timestamp-datatypes/
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With