简体   繁体   English

Qualtrics Javascript转换为ISO日期

[英]Qualtrics Javascript Convert to ISO Date

I'm trying to set up email triggers for surveys on Qualtrics but it's not properly converting to ISOformat. 我正在尝试为Qualtrics上的调查设置电子邮件触发器,但它没有正确转换为ISOformat。 Below is the code. 下面是代码。

Qualtrics.SurveyEngine.addOnload(function()
{
var date1Container = "${q://QID38/ChoiceTextEntryValue}".split("-");
console.log(date1Container);
var date2Container = "${q://QID40/ChoiceTextEntryValue}".split("-");

var date2 = new Date(date2Container[0], date2Container[1], 
date2Container[2] );
    date2.setHours(12,0);
    var date1 = new Date(date1Container[0], date1Container[1], 
date1Container[2] );
    date1.setHours(12,0);

var REM2 = new Date(date2);
    REM2.setDate(date2.getDate() - 1 );
    REM2.setMonth(date2.getMonth() - 1);
    REM2.setHours(8,30);
var REM1 = new Date(date1);
    REM1.setDate(date1.getDate() -1 );
    REM1.setMonth(date1.getMonth() - 1);
    REM1.setHours(8,30);

Qualtrics.SurveyEngine.setEmbeddedData( 'R1', REM1.toISOString() );
Qualtrics.SurveyEngine.setEmbeddedData( 'R2', REM2.toISOString() );


});

You should consider using moment.js . 你应该考虑使用moment.js Load moment.js in the survey header, then it can be used to parse and format the date: 在调查标题中加载moment.js,然后它可用于解析和格式化日期:

var REM1 = moment("${q://QID38/ChoiceTextEntryValue}").toISOString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM