当前位置:网站首页>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)
演示:
边栏推荐
- Summer safety is very important! Emergency safety education enters kindergarten
- Monthly observation of internet medical field in May 2022
- Ctfshow, information collection: web8
- Detailed explanation of Cocos creator 2.4.0 rendering process
- 【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类
- Whether runnable can be interrupted
- Points for attention in porting gd32 F4 series programs to gd32 F3 series
- 全日制研究生和非全日制研究生的区别!
- Nacos一致性协议 CP/AP/JRaft/Distro协议
- The download button and debug button in keil are grayed out
猜你喜欢

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

HW primary flow monitoring, what should we do
![[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)

Starting from 1.5, build a microservice framework link tracking traceid

Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list

【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)

Guangzhou Development Zone enables geographical indication products to help rural revitalization
![[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice](/img/f7/03975d08912afd8daee936799e8951.png)
[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
![[机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟](/img/38/cc5bb5eaa3dcee5ae2d51a904cf26a.png)
[机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟

微信小程序 01
随机推荐
[机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟
Points for attention in porting gd32 F4 series programs to gd32 F3 series
Mathematical modeling -- what is mathematical modeling
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
Unity's ASE achieves full screen sand blowing effect
[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)
[understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
什么是pv和uv? pv、uv
Ctfshow, information collection: web1
#HPDC智能基座人才发展峰会随笔
The rebound problem of using Scrollview in cocos Creator
Do not use memset to clear floating-point numbers
[follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code
Excerpted words
【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例
Zhongang Mining: Fluorite continues to lead the growth of new energy market
【数字IC验证快速入门】25、SystemVerilog项目实践之AHB-SRAMC(5)(AHB 重点回顾,要点提炼)
MySQL bit type resolution
Summer safety is very important! Emergency safety education enters kindergarten
MySQL bit类型解析








