Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs MySQL datetime formatting

So I have a bit of a weird issue. As far as I know, node-mysql should format datetime to javascript date objects. However, it's not.

This is the column: mysql> select order_time from jobs;

+---------------------+
| order_time          |
+---------------------+
| 2016-05-20 16:18:35 |
| 2016-05-20 16:24:47 |

The returned value looks like this:

2016-05-20T14:18:35.000Z

But it should look like this:

Fri May 20 2016 14:18:35 GMT+0200 (Central Europe Daylight Time)

Any ideas on why it gets misformatted?

like image 977
yusijs Avatar asked Nov 24 '25 11:11

yusijs


1 Answers

For anyone else struggling with this:

https://github.com/felixge/node-mysql/issues/1423

Basically date objects are changed in node v6+, and will always display as an isoString.

like image 199
yusijs Avatar answered Nov 26 '25 00:11

yusijs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!