200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Postman使用各种格式的时间戳转换(UTC Timestamp UnixTimeStamp)

Postman使用各种格式的时间戳转换(UTC Timestamp UnixTimeStamp)

时间:2021-12-25 10:48:14

相关推荐

Postman使用各种格式的时间戳转换(UTC Timestamp UnixTimeStamp)

很多人在使用Postman的时候, 可能会遇到一些需要时间戳的请求, 查了一些网站各种奇奇怪怪的方法, 都不适用, 这里根据postman community的建议, 使用moment.js 的三种转换方式最简单

如下:

在Postman的Pre-request script使用的示例:

var moment = require('moment');var current_timestamp = moment().format("YYYY-MM-DD H:mm:ss")pm.globals.set("current_timestamp",current_timestamp);pm.globals.set("current_unixtimestamp",moment().valueOf());//Get UTCconsole.log(moment());//Get Unix TimeStampconsole.log(moment().valueOf());//Get Normal TimeStampconsole.log(current_timestamp);

这样就可以配合pm.pm.variable将不同类型的时间戳应用到各个需要不同的时间戳的请求中了.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。