| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 6 |
<title>gettime</title> |
| 7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
| 8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
| 9 |
</head> |
| 10 |
|
| 11 |
<body> |
| 12 |
|
| 13 |
|
| 14 |
<h1>gettime</h1> |
| 15 |
|
| 16 |
<p> |
| 17 |
Gets current time. |
| 18 |
</p> |
| 19 |
|
| 20 |
<pre class="macro-syntax"> |
| 21 |
gettime <strvar> [<format> [<timezone>]] |
| 22 |
</pre> |
| 23 |
|
| 24 |
<h2>Remarks</h2> |
| 25 |
|
| 26 |
<p> |
| 27 |
Returns the current time in the string variable <strvar>, with the default format "HH:MM:SS". |
| 28 |
The user can specify the format same as <a href="http://msdn2.microsoft.com/en-us/library/fe06s4ak(VS.80).aspx" target="_blank">strftime</a>. And also, the default format equals "%H:%M:%S" at the <format> argument. |
| 29 |
</p> |
| 30 |
|
| 31 |
<p> |
| 32 |
The behavior of the gettime command specified with the format equals the getdate command specified with the same format.<br> |
| 33 |
When the <timezone> argument is specified as a timezone string, the timestamp is generated by using the timezone. |
| 34 |
When the <timezone> argument is not specified, the timestamp is treated as the localtime. |
| 35 |
</p> |
| 36 |
|
| 37 |
<p> |
| 38 |
This command returns one of the following values in the system variable "result": |
| 39 |
</p> |
| 40 |
|
| 41 |
<table> |
| 42 |
<thead> |
| 43 |
<tr> |
| 44 |
<th>Value</th> |
| 45 |
<th>Meaning</th> |
| 46 |
</tr> |
| 47 |
</thead> |
| 48 |
|
| 49 |
<tbody> |
| 50 |
<tr> |
| 51 |
<td>0</td> |
| 52 |
<td> |
| 53 |
Normal success. <strvar> is stored. |
| 54 |
</td> |
| 55 |
</tr> |
| 56 |
|
| 57 |
<tr> |
| 58 |
<td>1</td> |
| 59 |
<td> |
| 60 |
Error. <strvar> is not stored because a length of the generated string exceeds the upper limit -511 characters-. |
| 61 |
</td> |
| 62 |
</tr> |
| 63 |
|
| 64 |
<tr> |
| 65 |
<td>2</td> |
| 66 |
<td> |
| 67 |
Error. <format> is invalid. |
| 68 |
</td> |
| 69 |
</tr> |
| 70 |
</tbody> |
| 71 |
</table> |
| 72 |
|
| 73 |
<h2>Example</h2> |
| 74 |
|
| 75 |
<pre class="macro-example"> |
| 76 |
;Stores the current time to "timestr" variable with HH:MM:SS format. |
| 77 |
gettime timestr |
| 78 |
|
| 79 |
;Stores the current date with the user format to "logfile" variable. |
| 80 |
;The format is log-YYYYMMDD-HHMMSS.txt. |
| 81 |
gettime logfile "log-%Y%m%d-%H%M%S.txt" |
| 82 |
changedir 'C:\Test' |
| 83 |
logopen logfile 0 0 |
| 84 |
logwrite 'test data' |
| 85 |
logclose |
| 86 |
|
| 87 |
;To generate a GMT/UTC time stamp |
| 88 |
tz="GMT" |
| 89 |
gettime s "%Y/%m/%d %H:%M:%S" tz |
| 90 |
messagebox s tz |
| 91 |
</pre> |
| 92 |
|
| 93 |
<h2>See also</h2> |
| 94 |
<ul> |
| 95 |
<li><a href="getdate.html">getdate</a></li> |
| 96 |
<li><a href="http://msdn2.microsoft.com/en-us/library/fe06s4ak(VS.80).aspx" target="_blank">strftime (MSDN Library)</a></li> |
| 97 |
</ul> |
| 98 |
|
| 99 |
</body> |
| 100 |
</html> |