datestr function Unrecognized month format error

3 次查看(过去 30 天)
Hello :) could you help me with that error below?
"Error using matlab.internal.datetime.cnv2icudf (line 99) Unrecognized month format. Format: mmmmm dd, yyyy HH:MM:SS.FFF AM."
Those are my codes;
clc; clear; close all;
monday=datestr(now,'mmmmm dd, yyyy HH:MM:SS.FFF AM')

采纳的回答

Walter Roberson
Walter Roberson 2021-7-12
you have 5 m for the month field but datestr only permits up to 4 m

更多回答(1 个)

Seth Furman
Seth Furman 2021-7-14
We highly recommend using datetime in place of datestr, now, datenum, etc.
You can get a datetime version of the same value using datetime('now') and convert it to a text representation using the string function.
e.g.
dt = datetime('now','Format','MMMM dd, yyyy hh:mm:ss.SSS a')
dt = datetime
July 14, 2021 05:07:08.084 PM
txt = string(dt)
txt = "July 14, 2021 05:07:08.084 PM"

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by