The issue is your method is returning a boolean but in your test you are trying to assign it to a List of Opportunities:
List<Opportunity> op = controller.getRaisedDateandTime();
Try the following line instead of the one above:
Boolean differentHours = controller.getRaisedDateandTime();
In addition I would recommend reading the Apex Testing Best Practices and apply them to your test cases.
EDIT:
Upon further inspection there is issues with the lines -
apexPages.CurrentPage().getParameters().put('id',String.valueOf(Oppid.id));
ApexPages.StandardController sc = new ApexPages.StandardController(Oppid);
OppId in this case is actually defined as a List of Id's. The ApexPages.StandardController expects an instance of an sObject (e.g. Opportunity) therefore this should be changed to something like the following:
apexPages.CurrentPage().getParameters().put('id',String.valueOf(Oppid[0].id));
ApexPages.StandardController sc = new ApexPages.StandardController(Oppid[0]);
Fixing the lines highlighted will allow your test class to compile which in turn will allow the test method to provide some coverage on your method.
The way that your code reads here
List matchingDataGrid = [Select Id, Name, CreatedById, CreatedDate where Id = :defaultUserID];
for (List<myData> i :matchingDataGrid.Count)
You are assuming that matchingDataGrid is a list of lists, which it is not. You want to loop over each object within the list, so the format for doing that would be
for(myData i : matchingDataGrid)
The full code would look something like this.
public String matchingDataGridIDs {get;set;}
public void GetData(string defaultUserID)
{
//retrieve data for selected user
List<myData> matchingDataGrid = [Select Id, Name, CreatedById, CreatedDate where Id = :defaultUserID];
for (myData i :matchingDataGrid)
{
matchingDataGridIDs += i.Id + ',';
}
}
Best Answer
You get record type Id, you cannot extract name from it.