Solved

System Time and date  (Easy)

Posted on 1998-08-08
3
776 Views
Last Modified: 2012-05-04
How can i change  system date and time using delphi codes?

Some samples...  Thanks!
0
Comment
Question by:dia050398
  • 2
3 Comments
 
LVL 1

Expert Comment

by:pjdb
ID: 1361734
Assuming you don't care about the milliseconds, drop 6 edit boxes corresponding to years, month, day, hour, minutes and seconds and a button on a form. Put the folowing code in the onclick event of the button

procedure TForm1.Button1Click(Sender: TObject);
Var
 SysTime:TSystemTime;
begin
 FillChar(SysTime, SizeOf(SysTime), #0);      //initialize with 0
 With SysTime Do      //Store the data
 Begin
  SysTime.wYear:=StrToInt(Edit1.Text);
  SysTime.wMonth:=StrToInt(Edit2.Text);
  SysTime.wDay:=StrToInt(Edit3.Text);
  SysTime.wHour:=StrToInt(Edit4.Text);
  SysTime.wMinute:=StrToInt(Edit5.Text);
  SysTime.wSecond:=StrToInt(Edit6.Text);
 End;
 SetSystemTime(SysTime);
end;

NB : you can do exactly the oposite (from the system to your computer by reversing anything and using GetSytemDate instead of SetSytemTime

JDB
0
 

Author Comment

by:dia050398
ID: 1361735
This code can´t establish the TIME, maybe there´ll be another alternative code.
0
 
LVL 1

Accepted Solution

by:
pjdb earned 70 total points
ID: 1361736
Don't work?
I've forgot that it use UTC time...
Use GetLocalTime and SetLocalTime instead to work with your local time.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 156
delphi exception 7 64
control image tags in a string ? 12 129
I want to use librsync in my Delphi backup application. 3 47
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question