node-express如何在URL查询字符串中传递DATE参数,以及如何解析该参数

问题描述:

我有一个基于angular 2的应用程序,该服务的功能是发送http请求以从oracle DB,usind node-oracle db和express框架中获取数据. 我已经使用express构建了rest api,现在我需要在请求参数中传递DATE,而express必须对其进行解析并发送响应.我如何在查询参数中传递DATE以及如何在Express Rest API中解析它.

I have an app built on angular 2, a service in that sending http request to fetch the data from oracle DB, usind node-oracle db and express framework. I have built rest api's using express, now i need to pass the DATE in request parameter and express has to parse that and send the response. How can i pass the DATE in query param and how i can parse that in express rest api.

以iso格式'yyyy-mm-dd'传递日期

pass the date with iso format 'yyyy-mm-dd'

const date = new Date();
http.get(`url/test?date=${date.toISOString()}`

在快递方

app.get(/test', async function(req, res) {

const dateInServer = newDate(req.query.date);

});