postman断言

 

仅作为笔记:

// 获取当前时间
var moment = require('moment');
var currenttime = moment().format("YYYY-MM-DD HH:mm:ss");
pm.environment.set("currenttime",currenttime);

var myDate=new Date();

//自定义相对时间,默认自增10分钟
var customtime = myDate.getTime() + 10 * 60 * 1000;
var customtime = new Date(customtime);

var year = customtime.getFullYear();
var month = customtime.getMonth() + 1;
var date = customtime.getDate();
var hours = customtime.getHours();
var min = customtime.getMinutes();
var seconds = customtime.getSeconds();

//时间不足10位补0方案
month = month < 10 ? "0" + month : month;
date = date < 10 ? "0" + date : date;
hours = hours < 10 ? "0" + hours : hours;
min = min < 10 ? "0" + min : min; 
seconds = seconds < 10 ? "0" + seconds : seconds;

var nexttime = year + "-" + month + "-" + date + " " + hours + ":" + min + ":" + seconds;
pm.environment.set("nexttime",nexttime);

console.log("currenttime"+currenttime)
console.log("nexttime"+nexttime)

 

 

https://www.cnblogs.com/suim1218/p/8931159.html

https://blog.csdn.net/m0_38039437/article/details/95451423

https://www.cnblogs.com/enone/archive/2011/07/28/2119476.html

posted @ 2020-06-19 16:04  牵猫溜狗  阅读(236)  评论(1编辑  收藏  举报