Two issues here.
First and most important, "time" send it's output to stderr (standard error) not stdout, so that it will not be captured by normal redirection commands unless you take special measures.
Second, time is not a normal program but a special built-in command interpreted directly by the shell (for shells like bash, csh, tcsh, etc,). It thus works in a non-standard way and it times the whole rest of the command-line (unless you are using a very unusual shell).
So, to get the result you want (using bash), you need to use:
(time ls) 2>&1 | grep real
This will run the "ls" in a subshell and time it [ (time ls) ] , send standard error to standard out [ 2>&1 ] , and then send standard out to "grep" [ |grep ].
The last part that you used ">?dev/null" throws away the normal output from the ls command itself, in case that included the word "real."