Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set new sysdate from delphi 2.0, 3.0

Posted on 1998-01-14
8
Medium Priority
?
441 Views
Last Modified: 2010-04-04
I need a procedure that can change the system date and time

I use both win95 and NT
0
Comment
Question by:lpd
[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
  • 3
  • 3
  • 2
8 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356482
Are you using NT or 95?
0
 

Author Comment

by:lpd
ID: 1356483
Edited text of question
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 150 total points
ID: 1356484
Use the SetSystemTime api call.

E.g.  To set time to 20 May 1998, 10:30 a.m.

procedure SetNewSystemTime;
var
  SysTime: TSystemTime;
begin
  FillChar(SysTime, SizeOf(TSystemTime), 0);
  SysTime.wYear := 1998;
  SysTime.wMonth := 5;
  SysTime.wDay := 20;
  SysTime.wHour := 8;
  SysTime.wMinute := 30;
  SetSystemTime(SysTime);
end;


Note:  The hour will be 2 more than you specify on Win 95.  (NT???)

JB
0
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!

 
LVL 5

Expert Comment

by:ronit051397
ID: 1356485
Thank you

it works fine but, a have a small problem with timezones. the procedure that you wrote will set the time as if the timezone was GMT. Do you know how to see that timezone that currently is in use ?

0
 

Author Comment

by:lpd
ID: 1356486
Ah, that would explain why I need to -2 for hour!!

To get current timezone bias, use GetTimeZoneInformation.

E.g.
var
  MinutesDiff: Integer;
  TZInfo: TTimeZoneInformation;
begin
  GetTimeZoneInformation(TZInfo);
  MinutesDiff := TZInfo.Bias;
end;

In my case, MinutesDiff = -120 (i.e. 2 hrs behind).

JB
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1356487
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356488
P.S.  If you don't want do the TimeZone thing, use SetLocalTime instead of SetSystemTime.

JB
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1356489
Thanks agin
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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