_D
Convert millisecond timestamp or Date object to time string.
_D()
_D(timestamp)
_D(timestamp, fmt)Examples
-
Get and print current time string:
javascriptfunction main(){ var time = _D() Log(time) }pythondef main(): strTime = _D() Log(strTime)c++void main() { auto strTime = _D(); Log(strTime); } -
Timestamp is 1574993606000, convert using code:
javascriptfunction main() { Log(_D(1574993606000)) }pythondef main(): # Running on Beijing time server: 2019-11-29 10:13:26, running this code on a docker on another regional server results in: 2019-11-29 02:13:26 Log(_D(1574993606))c++void main() { Log(_D(1574993606000)); } -
Use parameter
fmtfor formatting. Format strings differ betweenJavaScript,Python, andC++languages. See the following examples for details:javascriptfunction main() { Log(_D(1574993606000, "yyyy--MM--dd hh--mm--ss")) // 2019--11--29 10--13--26 }pythondef main(): # 1574993606 is a second-level timestamp Log(_D(1574993606, "%Y--%m--%d %H--%M--%S")) # 2019--11--29 10--13--26c++void main() { Log(_D(1574993606000, "%Y--%m--%d %H--%M--%S")); // 2019--11--29 10--13--26 }
Returns
| Type | Description |
string | Time string. |
Arguments
| Name | Type | Required | Description |
timestamp | number / object | No | Millisecond timestamp or |
fmt | string | No | Format string. |
See Also
Remarks
Returns current time string when no parameters are passed. When using _D() function in Python strategies, note that the parameter passed should be a second-level timestamp (JavaScript and C++ strategies use millisecond-level timestamps, 1 second equals 1000 milliseconds). When using _D() function in live trading environment to parse timestamps into readable time strings, pay attention to the timezone and time settings of the operating system where the docker is located. The _D() function parses timestamps into readable time strings based on the local time of the docker system.