Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.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
javascript中的postgresql date_trunc()函数_Javascript_Postgresql - Fatal编程技术网

javascript中的postgresql date_trunc()函数

javascript中的postgresql date_trunc()函数,javascript,postgresql,Javascript,Postgresql,javascript中postgresqldate\u trunc()函数的替代方法是什么? 如果我键入pgsql,请执行以下操作: 选择日期('month',now()) 我会得到'2015-08-01 00:00:00-07' 如何使用javascript函数实现同样的功能 函数dateTruncate(间隔,日期){ 返回???; } 使用MomentJS $(“#结果”).text(矩()格式(“YYYY-MM-DD 00:00:00Z”) 最后使用的是力矩: function da

javascript中postgresql
date\u trunc()
函数的替代方法是什么? 如果我键入pgsql,请执行以下操作:

选择日期('month',now())
我会得到
'2015-08-01 00:00:00-07'

如何使用javascript函数实现同样的功能

函数dateTruncate(间隔,日期){ 返回???; } 使用MomentJS
$(“#结果”).text(矩()格式(“YYYY-MM-DD 00:00:00Z”)

最后使用的是力矩:

function dateTruncate(interval, date) {
    return moment(date).startOf(interval).toDate();
}

此解决方案只考虑截断到月份。月份应该是一个变量