postman中JS获取当前日期,当前日期后一个月日期

postman中JS获取当前日期,当前日期后一个月日期

#获取当前日期
var date = new Date();
var Month = date.getMonth() + 1;
var Year = date.getFullYear();
var date = date.getDate();
#判断月份小于9时月份格式为09; 大于9时月份格式为+1
if (Month < 9) {
Month = Month + 1;
Month = “0”+ Month;
}
else if (9 < Month < 12) {
Month = Month + 1;
Month = Month;
}
else {
Month = “0”+ 1;
Year = Year + 1;
}
if (date >= 0 && date <= 9) {
date = “0” + date;
}
#设置年,设置当前年月后一个月
pm.globals.set(“datayear”, Year);
pm.globals.set(“datamonthhh”, Month);

var date = new Date();
var Month = date.getMonth() + 1;
var Months = date.getMonth() + 1;
var Year = date.getFullYear();
var date = date.getDate();

if (Month < 9) {
Month = “0”+ Month;
}
else {
Month = Month;
}
if (date >= 0 && date <= 9) {
date = “0” + date;
}
var currentdatee = Year + “” + Month;
var currentdate = Year + “-” + Month + “-” + date;
#设置postman变量,当前月份,当前日期201909,2019-09,两种格式
pm.globals.set(“datamonthh”, Months);
pm.globals.set(“datamonth”, Month);
pm.globals.set(“datanow”, currentdate);
pm.globals.set(“datanoww”, currentdatee);
pm.globals.set(“datayear”, Year);

你可能感兴趣的:(自动化测试,postman,获取日期,JS)