convertTo
Convert datetime values to selected numeric representations.
📝Syntax
x = convertTo(t, 'datenum')
x = convertTo(t, 'posixtime')
x = convertTo(t, 'juliandate')
x = convertTo(t, 'exceltime')
x = convertTo(t, 'yyyymmdd')
📥Input Arguments
Parameter Description
inputs A datetime array and a conversion kind.
📤Output Arguments
Parameter Description
output A numeric array matching the requested representation.
📄Description

Convert datetime values to selected numeric representations.

convertTo centralizes the datetime conversions also available through datenum, posixtime, juliandate, exceltime, and yyyymmdd.

Array-valued inputs keep their data shape when the operation supports arrays. Scalar operands are expanded where the implementation defines scalar expansion.

💡Examples
Basic usage.
t = datetime(2024, 5, 17)
convertTo(t, 'yyyymmdd')
🔗See Also
datetimeduration
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub