node.JS中的日期格式 [英] date format in node.JS

查看:209
本文介绍了node.JS中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mysql数据库,因为我有一个名为request_date的字段.字段的类型为时间戳记,并且此字段中存储的数据的格式为2012-05-16 14:59:18. 但是当我通过Node.JS检索相同的数据时,数据在浏览器中显示为

I am using mysql database,in that i have a field by name request_date. The type of the field is time stamp and the data stored in this field has the format 2012-05-16 14:59:18. But when I retrieve the same data by Node.JS, the data is displayed in the browser as

Fri Jun 08 2012 15:16:50 GMT+0530 (India Standard Time)

为什么要进行这种格式更改?

Why this format change is happening?

我写了这个查询:

SELECT
biz_registration.reqid,biz_registration.request_date,biz_registration.req_status,biz_registration.annual_cost,biz_registration.rid,biz_contact.first_name,biz_contact.last_name
FROM biz_registration
INNER JOIN biz_contact ON biz_registration.reqid=biz_contact.reqid
ORDER BY biz_registration.request_date
DESC limit '+start+','+mlimit+''

我正在使用的html代码是

the html code i am using is,

options +='<div class="column" style="background-color: #E1E1E1;width:         100px;">'+result.reqid+'</div>';
options +='<div class="column" style="background-color: #E1E1E1;width: 160px;">'+result.request_date+'</div>';

推荐答案

我遇到了同样的问题,这解决了我的问题:

I was having the same problem, this fixed my problem:

您需要强制"您的mysql连接以立即对其进行格式化,并将其添加到您的配置(连接详细信息)中:

You need to 'force' your mysql connection to format it immediately, add this into your config(connection details):

host: 'localhost',
user: 'root'
// ....
dateStrings: 'date'

这篇关于node.JS中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆