I can get the system time using struct tm and time(),localtime(),asctime().but i need help about how i can set time of system using c program.
I can get the system time using struct tm and time(),localtime(),asctime().but i need help
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if you don’t want to execute a shell command you can (as you mentioned) use the settimeofday, i would start by reading the MAN page, or looking for some examples
here’s an example:
Shamelessly ripped From IBMs documentation, the
struct timevalstruct holds the number of seconds (as along) plus the number of microseconds (as along) from 1 January 1970, 00:00:00 UTC (Unix Epoch time). So you will need to calculate these numbers in order to set the time. you can use these helper functions, to better handle dealing with the timeval struct.