I’m trying to convert a ISO timestamp into a UNIX timestamp to test this converted value with the current value.
The date is 2018-02-15T00:33:02.000Z
Can this be converted into a UNIX timestamp within Postman?
Thanks in advance.
environment. set('currentdate', moment(). format(("YYYY-MM-DD"))); {{$timestamp}} -> predefined variable gets the current timestamp, Since you need date the above one should work.
Unix epoch timestamps are supported in the following formats: 10 digit epoch time format surrounded by brackets (or followed by a comma). The digits must be at the very start of the message. For example, [1234567890] or [1234567890, other] followed by the rest of the message.
In the Params tab, enter From in the Key column. Add the start date of your timeframe in the Value column — this must be in ISO format ( YYYY-MM-DD ). In the row below, enter To in the Key column and the end date of your timeframe in the Value column.
You can convert this time in Postman using moment.js which comes with the native application.
var moment = require("moment")
console.log(moment("2018-02-15T00:33:02.000Z").valueOf())
This would convert the value and print it on the Postman Console if you add this to the pre-request script
or Tests
tab.
This is always a good site for cross checking: http://currentmillis.com/
The same could be done in native JavaScript but moment makes it much easier.
The question is very vague as to what you are trying to do but this is a basic answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With