0

For a vuetify component I need the date but in a String or else I get this error

Invalid prop: type check failed for prop "now". Expected String with value "Thu Jan 02 2020 13:05:39 GMT-0600 (Central Standard Time)", got Date

How can I convert this to a String, the format is correct I just need it to be a String

$today = new Date();

3 Answers 3

1

You can use Carbon\Carbon for that. Something like Carbon::parse($today)->format(d-m-Y) for example

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

4 Comments

if I try this then I get DateTime::__construct() expects parameter 1 to be string, object given
what you put in parse method as parameter?
$today = new Date(); $now = Carbon::parse($today)->format("d-m-Y");
oh, that's easy one: Carbon::now()->format(d-m-Y) or whatever format you like
0

You can use the php date function, e.g:

$dateAsString = date('Y-m-d') // 2020-01-02

Comments

0
$today = new DateTime();
die($today->format(DateTime::RFC7231));

2 Comments

link only comment

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.