Solved

System Time and date  (Easy)

Posted on 1998-08-08
3
773 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now