1

I want to use the Postgres timstamp with timezone data type.

My migration has this line:

$table->dateTimeTz('local_timestamp');

I try to seed like this:

$note->local_timestamp = Carbon::now();

I have also tried to format it like this when I seed it:

$note->local_timestamp = Carbon::now()->format('Y-m-d H:i:sO');

I retrieve my seeded data like this:

$data = Note::where('owner', $owner)->get();

And I get an InvalidArgumentException "Data missing" in Carbon error that shows this:

at Carbon::rawCreateFromFormat('Y-m-d H:i:sO', '2019-03-28 14:02:42', null)

I have tried including this line in my model because I've seen it suggested as the answer on other similar questions:

protected $dateFormat = 'Y-m-d H:i:sO';
Andy
  • 2,095
  • 1
  • 29
  • 59

1 Answers1

0

Removing the date format from the model fixed the problem.

This answer is very useful - Laravel Carbon Data Missing

I changed the date format based on this answer - timestampTz fields in Laravel - which deals with the timestamptz data type (not datetimetz)

Andy
  • 2,095
  • 1
  • 29
  • 59