Convert date in normal format

3

I have this date 2018-08-24T04:47:51.000Z in an unknown format

How do I convert it to normal format, with javascript?

Should I use the library temporarily?

    
asked by hubman 28.08.2018 в 01:15
source

1 answer

2

I commented that you can use the MySQL function DATE_FORMAT() that as the first argument receives the variable or column where you have stored the date you want to improve in its format; after the second argument in quotes is the format you want to throw you in console

I leave this example, which should help you return formatted the date from the database itself to avoid granting that task or the backend or the frontend but of course you can do

Example

MariaDB [blog]> SET @Fecha = '2018-08-24T04:47:51.000Z';
Query OK, 0 rows affected (0.000 sec)

MariaDB [blog]> SELECT DATE_FORMAT(@Fecha, '%d/%m/%Y');
+---------------------------------+
| DATE_FORMAT(@Fecha, '%d/%m/%Y') |
+---------------------------------+
| 24/08/2018                      |
+---------------------------------+
1 row in set, 1 warning (0.000 sec)

The DATE_FORMAT() function receives the date as the first parameter and the mask that will format the data as the second parameter

DATE_FORMAT(fecha, máscara_a_usar);
    
answered by 28.08.2018 / 01:41
source