[Vuejs]-Passing a carbon date as a prop would return a computation in the vue template

0👍

Try removing vue binding : and use it as:

birthdate="{{ $user->profile->birthdate->format('m-d-Y') }}"

or keep : but wrap your string in single quotes.

:birthdate="'{{ $user->profile->birthdate->format('m-d-Y') }}'"

Or assign to a variable

:birthdate="myVar"

data(){
return{ myVar: "{{ $user->profile->birthdate->format('m-d-Y') }}"};
}

Because : or v-bind expects expression/variable, when you echo from PHP {{ $user->profile->birthdate->format('m-d-Y') }} as 12-21-2019 vue treats as integers with subtract not as string.

Leave a comment