Accessing Current Time & Different Timezone
1a. Accessing Current Time in Cypress:
We have to install the npm moment dependencies in order to access the Cypress.moment syntax.
Reference: https://momentjs.com/
Pre-requirements: 1. Install:
Examples: Let's get the Current time using Cypress.moment()
Get Current Time in AM/PM
Response: 1:47:33 PM Get Current Time in 24hrs
Response: 13:47:33
Get Current time in 24hours format & Adding 10 minutes
Get Current time in am/pm & Adding 10 minutes
Get the Current date & Add 10 days
1b) Accessing Time Zones in Cypress:
Additional to the above dependencies, We have to install the npm moment-timezone dependencies in order to work with moment.tz()
Pre-requirements:
1. Install:
Examples: Let's get time from the specified Timezone using Cypress.moment() Reference: https://momentjs.com/timezone/ Get CEST Timezone in Am/PM Here we are referring to CEST (Europe/Stockholm) Timezone
Response: 6:47:33 AM Get CEST Timezone in 24hrs
Response:06:47:33 Get time in 24 hours format & Adding 10 minutes
Response:06:57:33 TimeZone Parse and display dates: Reference: https://momentjs.com/timezone/ Time display Formats: Reference: https://momentjs.com/docs/#/displaying/
Last updated
Was this helpful?