?
Solved

System Time and date  (Easy)

Posted on 1998-08-08
3
Medium Priority
?
782 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 280 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

765 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