Skip to content
Discussion options

You must be logged in to vote
\Carbon\Carbon::serializeUsing(function ($date) {
    if (\Request::wantsJson()) {
        return $date->toJson();
    }

    return (string) $date; // Or any ->format() / translated ->isoFormat() or ->calendar() you want
});

Would allow you to change output for view vs. JSON as you like.

But when using Vue.js, I would recommend to keep ISO 8601 string and use UTC instead local timezone for the storage as string in your JS variables.

When you'll pass those to new Date() or HTML component, the browser should convert it just fine in local timezone.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dillingham
Comment options

@kylekatarnls
Comment options

@dillingham
Comment options

@kylekatarnls
Comment options

@dillingham
Comment options

Answer selected by dillingham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants