This question is for demonstrative purposes. How can I tell my application to uninstall after a certain period of time is over? May or may not be possible. Just wondering...
This is a recipe for disaster. Users don't like programs that change things against their will. There are lots of solutions out there to expire the software and inform your users of the advantages of purchasing it after the trial period.
Assuming you are using windows installer schedule a task in windows task scheduler to execute msiexec /u (your productcode) /q
(exact syntax of args may take some tweaking)
Platform would be important to address this adequately.
You could setup a scheduled process (cron on Linux, Windows Scheduler, etc.), to check the date and invoke the uninstall.
I'd suggest that you simply refuse to run after a certain date and put the check in your code... using a license file or some other type of security mechanism.
There are several commercial products that can help you lock down your application. I'd suggest finding and using one, because someone could simply remove your uninstall hook or run a script to "crack" your application in a few minutes. It depends on if you need to uninstall, or if this is simply a deterrent.