Modify system time (Windows, Linux)

Source: Internet
Author: User

System modification time in Windows

Void uimanager: setpolicime () {// # include <windows. h> // # include <stdlib. h> systemtime s; // getlocaltime (& S); // setlocaltime (& S) // The Greenwich Mean Time obtained by getsystemtime (), which is the global standard time. Setsystemtime (& S) s. wyear = 2000 + temp [0] * 10 + temp [1]; S. wmonth = temp [2] * 10 + temp [3]; S. wday = temp [4] * 10 + temp [5]; S. whour = temp [6] * 10 + temp [7]; S. wminute = temp [8] * 10 + temp [9]; If (setlocaltime (& S) cout <"setting time is success" <Endl; else cout <"setting time is not success" <Endl ;}

 

Linux system modification time

Void uimanager: sethwcolock (string datetime) {string d = "sudo date-s '" + datetime + "'"; // enter the password, remove sudo System (D. c_str (); System ("sudo hwclock -- systohc"); // to enter the password, remove sudo // system ("sudo hwclock") from the Board "); // verify whether the modification is successful}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.