How can I put the current date and time in my log files?
|
Title
|
|
Current date and time
|
|
Author
|
Jeremy B. Wernow, StataCorp
David Kantor, Johns Hopkins University
|
|
Date
|
June 2000; updated February 2003
|
You can put the current date and time into your log files by displaying the
global macros where these values are stored.
For example,
. display "$S_DATE"
14 Feb 2003
. display "$S_TIME"
15:53:01
. display "$S_TIME $S_DATE"
15:53:17 14 Feb 2003
The current date and time are also available as part of the c()
class, see help
creturn.
. display c(current_date)
14 Feb 2003
. display c(current_time)
15:56:05
. display "`c(current_time)' `c(current_date)'"
15:56:32 14 Feb 2003
David Kantor suggests the following ado-file:
*! version 1.0
* Datetime procedure. Just displays the date and time.
* Good for use in logged sessions.
* By David Kantor. 9-26-97
version 7.0
program define datetime
disp "DateTime: $S_DATE $S_TIME"
end
It is then easy to include datetime in your do-files.
|