Add time to datetime format
Mostrar comentarios más antiguos
Hi,
I have a datetime format in the following format (MM-dd-yyyy), but it does not have time. How can I add time to it for instance 00:00 (midnight) so I get the format MM-dd-yyyy HH:mm:ss.
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 23 de Ag. de 2020
Editada: Steven Lord
el 23 de Ag. de 2020
A datetime array generally has a time component, even if it's not shown[*].
>> dt = datetime('today')
dt =
datetime
23-Aug-2020
>> dt.Format = 'dd-MMM-yyyy hh:mm:ss a'
dt =
datetime
23-Aug-2020 12:00:00 AM
[*] From the documentation for datetime: "Datetime values later than 144683 years CE or before 140743 BCE display only the year numbers, regardless of the specified Format value."
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!