A reference is valid only as long as the referred to object is valid.
The function that you have posted should not return a reference. Not only does the reference lack any benefit, but the construct is dangerous.
Just to be clear for the OP:
The returned reference in your example is invalid because "int t" is being passed by value, not by reference, and is therefore being copied to your setdate function.
In other words, int t is not the same variable that you passed to the setdate function; it is only a copy of it. t only exists as a valid variable in memory for the duration of the function block. After the function ends, t is popped off the stack, and the reference to it becomes invalid.