How to achieve the aim that execute different function in different time interval by the timeline.

Hello:
The function I want to achieve is just like that(not by czml,because function in different time interval could be computing different data ):

when the pointer in timeline is from 02:00:00 to 04:00:00,function1 will be executed;

when the pointer in timeline is from 04:00:00 to 06:00:00,function2 will be executed;

I try to achieve it but I lose,I need some idea please.