1. Same as you would in a C application.
2. Ditto - you can't.
1. Why? Call system("ntpdate ntp_server_address") - this will set the system time to the global clock. Guaranteed accurate. If you want to set it to your own value, use system("date date+time_value").
2. The problem here is that you will need to input the password for the root account, and that cannot be done if the process is being run in the background. So, for security reasons, you really can't do that. In a shell, running the command "su -" will request the password for the root account, and if the calling process is backgrounded (no stdin), then it will fail.
idea what u have give worked for me, but slight different i.e at the time of installing OS we need to do chmod +s /usr/bin/date command at super user ...
after doing this, we can change from any user ....