What's the difference between timestamps() and timestampsTz() methods in the Laravel's Schema Builder? I tried searching google but couldn't find any help.
Basicly timestampsTz() stands for Timestamp with Timezone
while timestamps() is like Timestamp without timezone
TimestampsTz()
is a representation for a specific point in time. The adjustment to this time is made by the timezone that is related to your system.
The normal timestamps()
is more a representation like normal clock.
Have a look at this example:
If you are using the timestamps()
function you will also store the timezone that was chosen by your environment. If you are using the timestampsTz()
you will not safe the timezone.
I guess it would be good practice to use timestamp without timezone
when all your data is for sure in the same zone, or you got another layer over there which handles the time conversion.
Update:
In the Database the normal timestamps()
will look like
2004-10-19 10:23:54
while the timestampsTz()
looks like
2004-10-19 10:23:54+02
Update 2:
These functions are in Laravel available for every type of Database. But this only differs for PostgreSQL. Have a look at the docs: PostgreSQL Timestamp. In the other databases the timezone information is included in the timestamp automatically.
In all other databases this will have the same output.
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