0

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.

1
  • Is it possible to send the date from Laravel to send a standard format? The Date(string) constructor relies on Date.parse(string) which considers mainly ISO format such as 2020-08-03? Otherwise, you have to manually parse the API response. Commented Aug 4, 2020 at 2:44

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.