Have a look to this post.
Do a toogle button that have 2 status : Run/Stop. So you will push your button and do
if (get(hObject,'value'))
set(handles.toogleRun,'string','stop');
else
set(handles.toogleRun,'string','Run');
end
while (get(hObject,'value'))
txt=datestr(now);
set(handles.datetime,'string',txt);
drawnow;
end
This is the callback for the toogleRun button.
EDIT : So for using the timer instead use that code :
function my_callback_fcn(obj, event)
txt = datestr(now)
set(handles.datetime,'string',txt);
And into your Opening GUI function create a timer and set is callback function to the function you already create.
t = timer('StartDelay', 1, 'Period', 0.1);
t.TimerFcn = {@my_callback_fcn};
So just add start(t) on a button or whatever