当前位置:网站首页>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)
演示:
边栏推荐
- 简述keepalived工作原理
- Introduction of mongod management database method
- HPDC smart base Talent Development Summit essay
- Unity's ASE realizes cartoon flame
- "Baidu Cup" CTF competition 2017 February, web:include
- [understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
- A need to review all the knowledge, H5 form is blocked by the keyboard, event agent, event delegation
- 15. Using the text editing tool VIM
- Qu'est - ce qu'une violation de données
- 【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
猜你喜欢

【OBS】RTMPSockBuf_ Fill, remote host closed connection.

Write sequence frame animation with shader

Ctfshow, information collection: web12
![[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)
![[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)](/img/91/16a370ac41adc8fe31507765a82b0a.png)
[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)

The download button and debug button in keil are grayed out

Ctfshow, information collection: web7
![[Lanzhou University] information sharing of postgraduate entrance examination and re examination](/img/06/df5a64441814c9ecfa2f039318496e.jpg)
[Lanzhou University] information sharing of postgraduate entrance examination and re examination

HPDC smart base Talent Development Summit essay

【目标检测】YOLOv5跑通VOC2007数据集
随机推荐
Connecting FTP server tutorial
2.Golang基础知识
Oracle control file loss recovery archive mode method
How to deploy the super signature distribution platform system?
[markdown grammar advanced] make your blog more exciting (IV: set font style and color comparison table)
Points for attention in porting gd32 F4 series programs to gd32 F3 series
Yunxiaoduo software internal test distribution test platform description document
STM32F103C8T6 PWM驱动舵机(SG90)
微信小程序 01
【搞船日记】【Shapr3D的STL格式转Gcode】
一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
The difference between full-time graduate students and part-time graduate students!
Share the technical details of super signature system construction
HPDC smart base Talent Development Summit essay
全日制研究生和非全日制研究生的区别!
使用cpolar建立一个商业网站(2)
Window环境下配置Mongodb数据库
[quick start of Digital IC Verification] 23. AHB sramc of SystemVerilog project practice (3) (basic points of AHB protocol)
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
What is data leakage








