R
R
Roman Sarvarov2021-01-26 10:52:59
Laravel
Roman Sarvarov, 2021-01-26 10:52:59

Converting the date to the format - on the backend or frontend?

I'm making a website with Laravel + Vue.js.
Laravel returns data from the database, among which there are values ​​in the form of a date and time.
The user in the browser needs to display this date in a certain format, for example "dmY H:s".
Do you think it's better to do it on the API side (using Carbon) or on the front end (using some momentjs)?
As I understand it, the latter is slower, but more manageable in the future.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-01-26
@megakor

The date is sent from the back in UTC.
At the front, it is formatted and displayed already in the local time zone.
For formatting, no third-party libraries are needed (Depends on the browsers you need to support)
https://developer.mozilla.org/ru/docs/Web/JavaScri...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question