Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime

Status
Not open for further replies.

woodcarver

Technical User
Oct 11, 2001
20
US
Hi again:I'm another project and need to know a few small things, A}how does one display the current date and time.
B}this app needs to be executed at a certain time-i.e. 1am
for example, how do I access the clock in Windows in order to make this possible? this app will have a loop running in TaskManager. Thanks
 
For the current time use:
Code:
TDateTime TheTimeIs = Time();
String StringTime = TimeToStr(TheTimeIs);

For the current date use:
Code:
TDateTime TheDateIs = Time();
String StringDate = DateToStr(TheDateIs);

To get both in one swoop use:
Code:
TDateTime ItIs = Now();
String StringNow = DateTimeToStr(ItIs);

Look at SysUtils in your help file a slew of date and time function.

For the second part, it depends on what you mean by this app needs to be executed at a certain time. Do you mean the app is running and something has to happen at 1 AM? If this is the case, look at the TTimer component.

If you mean the app needs to be started at 1 AM, look at Window's Scheduler. Clear as mud now? James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Opps! [blush] The date should have been:
Code:
TDateTime TheDateIs = Date();
String StringDate = DateToStr(TheDateIs);
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
2ffat:the app will be started at 'x' time and iniate a series of small programs{similar to a 'programmable logic controller' program such as in a manufacturing facility to operate production line operations.
 
So it sounds like you need to use a scheduler. Do you want to write your own scheduler or user Windows?
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top