How to save current date as unix timestamps in Postgres?
Now, i'm saving my date this way:
$link->created = Carbon::now();
But in postgre i'm getting '2019-08-29' kind of date, so i cannot reformat it on my frontend with hours, minutes, seconds. What's the correct way on saving current date with Carbon?
@alexanderkim well, the DATE type stores only DATE without time, you need to change your column data type in order to store the hours, minutes and seconds.
In MYSQL would be: from DATE type, to DATETIME type
Postgres is a bit different in this case, i've tried to save current date as Carbon::now()->timestamp, so the date would like unix timestamp 453412334123, but postgres won't save this in date, dateTime, timestamp field, throw ERROR 7 with overflow thing.
Seems that postgres does not have a DATETIME column type.
You could make it an integer at save it as as an unix timestamp.
And then add a mutator for the column to convert it to carbon automatically.