当前位置:网站首页>postman生成时间戳,未来时间戳
postman生成时间戳,未来时间戳
2022-07-07 13:24:00 【Test-超哥】
支持获取:当前时间戳、未来时间戳、指定时间戳、当前年月日、未来年月日
- 获取当前时间戳
//获取当前时间戳
let timestamp = (new Date()).getTime().toString();
//控制台输出时间戳
console.log("当前时间戳:",timestamp)
//把startDate 设置时间戳为环境变量
pm.environment.set("startDate", timestamp);
演示:
- 指定日期,生成时间戳
//制定日期时间戳
var data_f = new Date(2022,7.05);
var appoint = data_f .getTime()
console.log("指定日期时间戳:",appoint)
pm.environment.set("expiration", appoint);
演示:
- 获取未来时间戳
// 获取当前时间格式为年月日
var date = new Date();
// 设置当前时间为3天后
date.setDate(date.getDate() + 3)
// 查看修改是否成功
console.log(date)
// 把修改后的时候,转换为时间戳
var toTimes = date.getTime()
// 查看时间戳
console.log(toTimes)
// 把 toTimes 设置为 expirationDate 环境变量
pm.environment.set("expirationDate", toTimes);
演示:
- 获取未来时间戳 之 “沙雕方法”:

//未来时间戳
let appoint = new Date().getTime();
// 三天总毫秒=259200000
appoint=appoint+259200000
console.log('72时的时间戳', appoint)
pm.environment.set("expirationDate", appoint);
演示:
- 获取:年月日 (YYYYMMDDHHmmss)
// 引用第三方库 :moment 等同于 import moment from 'moment'
var moment = require('moment');
// 调用 moment()方法获取当前时间,并进行格式化,用变量 currentRime 接收
var currentTime = moment().format(" YYYYMMDDHHmmss");
// 打印当前时间的值到控制台
console.log("当前时间是:", currentTime);
// 放到环境变量里
pm.environment.set("beginTime", currentTime);
演示:
- 获取未来时间:10分钟后的年月日
// 引用第三方库 :moment 等同于 import moment from 'moment'
var moment = require('moment');
// 未来时间,比如:当前时间的10分钟后,精确到秒
var beginTime = moment().add(10,"m").format(" YYYYMMDDHHmmss");
// 开始时间,当前时间的1小时后,精确到秒
var endTime = moment().add(1,"H").format(" YYYYMMDDHHmmss");
console.log("10秒后时间:", beginTime);
console.log("1小时后时间:", endTime);
演示:
- 年月日格式: 2022-07-04T11:27:15
// 72小时后的年月日时间
var moment = require('moment');
var YTD = moment().add(72,"H").format(" YYYY-MM-DDTHH:mm:ss");
console.log("72时后的年月日时间:",YTD);
// 设置为变量
pm.environment.set("tokenExpirationTime", YTD);
演示:
- 生成当前时间,类型为:“2022-07-01T05:18:17.580Z”
var a = new Date()
console.log("当前时间:",a)
演示:
- 生成后三天时间
var a = new Date()
a.setDate(4)
console.log("未来时间:",a)
演示:
边栏推荐
- 众昂矿业:萤石继续引领新能源市场增长
- [quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
- Nacos一致性协议 CP/AP/JRaft/Distro协议
- Runnable是否可以中断
- Cocos uses custom material to display problems
- Unity's ASE achieves full screen sand blowing effect
- [make a boat diary] [shapr3d STL format to gcode]
- 【目标检测】YOLOv5跑通VOC2007数据集
- TypeScript 发布 4.8 beta 版本
- unnamed prototyped parameters not allowed when body is present
猜你喜欢

【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)

【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例
![[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)](/img/7e/188e57ee026200478a6f61eb507c92.png)
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)

Zhongang Mining: Fluorite continues to lead the growth of new energy market

有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
![[follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code](/img/8d/a6d477a8679ca4f3885b1a7b542437.png)
[follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code
![[quick start of Digital IC Verification] 24. AHB sramc of SystemVerilog project practice (4) (AHB continues to deepen)](/img/cf/45775b712f60869186a25d3657ee1b.png)
[quick start of Digital IC Verification] 24. AHB sramc of SystemVerilog project practice (4) (AHB continues to deepen)

Yunxiaoduo software internal test distribution test platform description document

【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)

The bank needs to build the middle office capability of the intelligent customer service module to drive the upgrade of the whole scene intelligent customer service
随机推荐
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
[understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
Points for attention in porting gd32 F4 series programs to gd32 F3 series
[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
居然从408改考自命题!211华北电力大学(北京)
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
Super signature principle (fully automated super signature) [Yun Xiaoduo]
[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
2. 堆排序『较难理解的排序』
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
摘抄的只言片语
【数字IC验证快速入门】24、SystemVerilog项目实践之AHB-SRAMC(4)(AHB继续深入)
Nacos conformance protocol cp/ap/jraft/distro protocol
Write sequence frame animation with shader
一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
The rebound problem of using Scrollview in cocos Creator
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)








