Reputation: 171
I need to test an agenda and I need getting the actual date and current hour to assert with the agenda values.
This not works:
var d = new Date();
expect(day.getText()).toEqual(d.getDate());
Upvotes: 0
Views: 4495
Reputation: 6962
You can get current hour using JavaScript inbuilt getHours()
method. Here's its usage -
var cTime = Date().getHours();
or
var d = new Date();
var cTime = d.getHours(); //prints the current hour only
And you can get the actual date using getDate()
method which prints a string of values related to current date and time. Sample format: Fri Nov 20 2015 20:24:38 GMT+0530 (IST)
. Hope it helps
Upvotes: 2