Fiorella Del Solar
Fiorella Del Solar

Reputation: 399

Format date of Json from Laravel in Vue

I have a problem, I pass a date in d / m / Y format to Vue from Laravel and I want to increase it by one month, but when I try to do:

From laravel send it as a JSON collection:

'date' => date ('d/m/Y', strtotime ($row->date)),

03/08/2020

In Vue:

let nextdate = new Date(date);

I get the day and the month reversed.

Sun Mar 08 2020 00:00:00 GMT-0500 (Peru standard time)

It should come out, August 3, 2020.

Upvotes: 0

Views: 609

Answers (1)

mmabdelgawad
mmabdelgawad

Reputation: 2545

Try this

Carbon\Carbon::make($row->date)->setTimezone('America/Lima')->addMonth()->format('d/m/Y');

don't forget to double check your timezone America/Lima you can find your timezone Here

Upvotes: 1

Related Questions