Remove time from datetime
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
vidit kedia
am 21 Jan. 2021
Kommentiert: vidit kedia
am 21 Jan. 2021
I would like to remove the time from a datetime element, without using the .Format = 'dd-MMM-yyy', as this only chages the display format but the time component is still present in the element.
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 21 Jan. 2021
Bearbeitet: Steven Lord
am 21 Jan. 2021
Use timeofday to create a duration array containing the time since midnight for each of the datetime arrays.
rightNow = datetime('now')
timeSinceMidnight = timeofday(rightNow)
And since I'm guessing you may be trying to "split" the datetime:
todaysDate1 = dateshift(rightNow, 'start', 'day') % or
todaysDate2 = rightNow - timeSinceMidnight
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!