Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node/JavaScript日期时间和MySQL_Javascript_Mysql_Datetime - Fatal编程技术网

Node/JavaScript日期时间和MySQL

Node/JavaScript日期时间和MySQL,javascript,mysql,datetime,Javascript,Mysql,Datetime,调用从Node/JS应用程序接收“datetime”参数的MYSQL存储过程似乎无法正常工作 从sql中调用MySQL过程可以正常工作,但不能从JS中调用。这是我的psuedo代码: //procedure Proc(IN startDate datetime) {... select * from tbl where start = Date(datetime) ..} //this works ok from sql Call Proc (NOW()) //From Node/

调用从Node/JS应用程序接收“datetime”参数的MYSQL存储过程似乎无法正常工作

从sql中调用MySQL过程可以正常工作,但不能从JS中调用。这是我的psuedo代码:

 //procedure
 Proc(IN startDate datetime) {... select * from tbl where start = Date(datetime) ..}

 //this works ok from sql
 Call Proc (NOW())

 //From Node/JS, these don't seem to get the correct results
 connection.query(call proc(new Date())
 connection.query(call proc(getFormattedDate(new Date())
编辑:我正在使用此函数返回格式化日期

var getFormattedDate = function(Date_toYMD) {
Date.prototype.toYMD = Date_toYMD;

    var year, month, day;
    year = String(Date_toYMD.getFullYear());
    month = String(Date_toYMD.getMonth() + 1);
    if (month.length == 1) {
        month = "0" + month;
    }
    day = String(Date_toYMD.getDate());
    if (day.length == 1) {
        day = "0" + day;
    }
    return year + "-" + month + "-" + day;

})

今天的日期在JavaScript中的工作方式如下:

var dt = new Date;
console.log(dt.getFullYear()+'-'+(++dt.getMonth())+'-'+dt.getDate());

这就是我所拥有的。我上面的代码是伪代码,但我使用的函数与您的var getFormattedDate=functionDate\u toYMD{Date.prototype.toYMD=Date\u toYMD;var year,month,day;year=StringDate\u toYMD.getFullYear;month=StringDate\u toYMD.getMonth+1;if month.length==1{month=0+month;}day=StringDate_toYMD.getDate;if day.length==1{day=0+day;}返回年+-+月+-+日;};