如何格式化月份中没有前导零的日期?
How do I format a date without a leading zero in month?
密码是
time.ToString("yyyyMMddHmmsFFF"));
它 returns“20190121153530”在 2019 年之后带有前导零。
如何格式化日期以获得不带前导零的“2019121153530”?
MM
在您指定的格式中将使用 "The month, from 01 through 12".
M
格式将使用 "The month, from 1 through 12"。如:
time.ToString("yyyyMddHmmsFFF"));
有关 DateTime
字符串格式的更多选项,请参阅“Custom Date and Time Format Strings”。
密码是
time.ToString("yyyyMMddHmmsFFF"));
它 returns“20190121153530”在 2019 年之后带有前导零。
如何格式化日期以获得不带前导零的“2019121153530”?
MM
在您指定的格式中将使用 "The month, from 01 through 12".
M
格式将使用 "The month, from 1 through 12"。如:
time.ToString("yyyyMddHmmsFFF"));
有关 DateTime
字符串格式的更多选项,请参阅“Custom Date and Time Format Strings”。