Traditional Culture Encyclopedia - The 24 Solar Terms - Who knows how to get "hour-minute-second" time in DELPHI?
Who knows how to get "hour-minute-second" time in DELPHI?
1 to get the current date and time.
In delphi language, date and time are defined by using TDateTime data type. To get the current date (including time), you can use the Now function:
2. Format and output the obtained current date and time data as required.
If you need to display the output of TDateTime data in a custom format, you can use the FormatDateTime function:
Among them, the format parameters can be set with various predefined identifiers. Here are some commonly used identifiers:
After understanding the above knowledge, you can try to write code. The following is sample code:
Program? TForm 1。 Button 1Click (sender:? to object);
defined variable
s:? String;
Coagulation time? :TDateTime
begin
Coagulation time? :=? Now; //Get the current date and time
s? :=? FormatDateTime ('now? yyyy? Year? m? Month? d? Day? hh? What time? nn? Integral? ss? Seconds', curdatetime);
MessageBox (handle, PChar(s),? Information prompt',? MB_OK? +? MB _ icon information);
End; Screenshot of code running:
- Previous article:Zhengzhou Nissan np300 has a low idle speed.
- Next article:Seven spring health porridge recipes
- Related articles
- What are the songs suitable for writing American literature in March 8th?
- There are sighs and surprises in the preview of Beijing Auto Show, and nearly 20 brands regret being absent!
- 202 1 which day should we pay attention to in the severe cold?
- 1968 is it a flat year or a leap year?
- 6000km 1.6T peugeot 3008 maintenance operation
- Human fireworks composition
- When is the best time to prune the vines?
- That poem describes the phenological characteristics of the slight cold solar terms.
- After cold dew, paying attention to these three points is much more useful than taking tonic.
- How to fertilize grapes?