GetDateAndTime

Do you come across test cases where you need to fetch the date and time in a specific format? For example - You wish to fetch the contract period from an employee's record working in a different time zone and convert it into mmddyy from DDMMYY.

Opkey with its Utility_GetDateandTime keyword helps eliminate the usage of a dozen keywords in capturing the data, converting it to the date and time format, performing calculations, evaluating the results, getting the output, and displaying it to you. All this can now be done with the help of using Opkey’s Utility_GetDateandTime keyword. This keyword will let you perform three operations by using only one single keyword :

  1. Get the current date and time

  2. Convert it into the desired format.

  3. Calculate and share the required results

Let us have a look at how we can do it:

  1. Get the current date and time

  • Login to Opkey Web and select a Project to work on.

  • Create a test case and add the keyword GetDateandTime

  1. Convert it into the desired format.

  • In the Input data add the required date and time format that you need

  • Save the details and execute the test case.

The keyword will fetch the current date and time and convert the retrieved data in the format mentioned in the above steps.

The available date and time formats are as mentioned below.

M, MM - Month 

d, dd - Date 

yy, yyyy - Year 

m, mm - Minutes 

h, hh - Hours 

s, ss - Seconds 

tt - AM/PM

dd, dd - Days

If you want to get the Day as the output for any given Date, you’ll have to provide D as input. This will provide you with the output as the “Monday, 21st February, 2022”.

  1. Calculate and share the required results

You can also calculate and get the past and present date and time using this keyword. 

  • To do that click on the Input Data and enter the desired time or date.

Click on OK button and save the details. And execute the run to get the desired output.

Now you see the output is different than the current date and time as the entered details are of a future date.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article