0

In a Flask project, I did a function that returns a list of dates picked from the database. I take that result in a javascript function to put in a HTML tag. But I get dates in a JSON format as below:

{'0': datetime.datetime(2019, 9, 13, 17, 13, 34), '1': datetime.datetime(2019, 9, 13, 19, 06, 20)}

This is what I get in my HTML page, and I would like to know if there is a way to simplify it in order to get it like this:

<table>
  <tr>
    <td>13/09/2019 17:13</td>
  </tr>
  <tr>
    <td>13/09/2019 19:06</td>
  </tr>
</table>
<style>
  table,
  td {
    border: 1px solid #333;
  }
  
  thead,
  tfoot {
    background-color: #333;
    color: #fff;
  }
</style>

In a way that can fit into a simple table no matter how many dates I get from the database.

I tried with JSON.parse() and JSON.stringify(), but it didn't recognize the python datetime (Console output: datetime is not defined).

How can I use this JSON information in a JavaScript function?

Thank you.

2

0

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.