on-internet
← Community

How to use the current date/time in an API call?

Stack Overflow ·

I have a test that makes an API call, and a required part of the body that I'm passing in is a timestamp. The whole test is working except for this last piece (if I manually set the date/time before each test execution the test succeeds). I have been trying to set a variable like this: const todaysDate = Cypress.moment().format('YYYY-MM-DDTHH:MM:SS-07:00'); but I cannot figure out how to use this in the API call. The API parameter is formatted as such: "offDateTime": "YYYY-MM-DDTHH:MM:SS-07:00" Can anyone help me out?

Comments

Sign in or sign up to comment and upvote.

No comments yet.