How to handle data passed by Answer in jQuery

Asked

Viewed 69 times

-2

Just after making a render of a screen as in the example below:

( return res.status(200).render("mschedule", { erro: {}, list: teste }) )

I would like to manipulate a return data (list) in jquery.

How can I handle (list) that was passed on the render on the front to display the formatted date

Ex: list.data(11/03/2019), I would like to take this data in the front Jquery and format this date to the format "Monday 11 May 2019".

  • Could you elaborate a little more on your question?

  • This 'Sponse' Voce achieves this from where, an AJAX?

2 answers

0


the answer I wanted was this, I used a Framework Moment to have a more personalized return of the dates

const Moment = require('Moment') Moment.updateLocale('en', { months: [ "Jan", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" ], weekdays: [ "MON", "B", "WED", "THU", "FRI", "SAB", "SUN" ] });

here I changed the return desired

Let data = await app.db('viewc') . select('*') . orderby('date', 'desc') . orderby('time', 'desc') for (Let i = 0; i < date.length; i++) { date[i]. date = Moment(date[i].date). format('DD/MMMM') date[i]. day = Moment(date[i]. date). format('dddd') }

0

So, if I understand correctly, you want something like this:

data = new Date("2017-08-21");
var options = {
  weekday: 'long',
  year: 'numeric',
  month: 'long',
  day: 'numeric'
};
console.log(
  'A data é:',
  data.toLocaleDateString('pt-BR', options)
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.