Data Type Conversion and Conversion Functions
Figure 1 illustrates details about the conversion between datetime strings, datetime objects, and Unix timestamps, along with the corresponding conversion functions.
Table 1 details the specific conversion scenarios and functions.
|
Conversion Scenario |
Conversion Function |
|
|---|---|---|
|
Conversion between datetime objects and Unix timestamps |
Converting a datetime object to a Unix timestamp |
|
|
Converting a Unix timestamp to a datetime object |
|
|
|
Conversion between datetime objects and datetime strings |
Converting a datetime object to a datetime string |
|
|
Converting a datetime string to a datetime object |
|
|
|
Conversion between datetime strings and Unix timestamps |
Converting a datetime string to a Unix timestamp |
Intelligent conversion function: dt_parsetimestamp, which converts a datetime string or datetime object to a Unix timestamp. |
|
Converting a Unix timestamp to a datetime string |
|
|
The preceding figure and table outline six conversion types among the three data types. Each conversion type offers two methods: using an intelligent conversion function or a dedicated conversion function.
- Intelligent conversion functions
These functions (for example, dt_parse) can accept parameters of various types, such as Unix timestamp, datetime object, and datetime string, to intelligently perform the conversion.
- Dedicated functions
Intelligent conversion functions may meet all user requirements. For example, if a user specifies a unique or non-standard date format, intelligent functions like dt_parse may fail to automatically parse the log data. In such cases, a dedicated function like dt_strptime must be used to parse the specified format.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
