日期时间日/月 (02/12)

发布于 2024-10-05 09:49:52 字数 140 浏览 0 评论 0原文

这似乎是我应该能够在谷歌上找到的东西,但我没有太多看。

我想将日期格式设置为日/月。我唯一发现的是 {0:M},它显示了我想要的信息,但是月份写得像 12 月而不是“12”。由于空间限制,我需要尽可能使用 02/12。

感谢您的帮助!

This seems like something I should be able to find on Google but I'm not having much look.

I'd like to format a date as day/month. Only thing I've found it {0:M} which displays the information I want however the month written out like December rather than "12". I need to use 02/12 if possible due to space restrictions.

Thanks for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

唐婉 2024-10-12 09:49:52

您可以尝试以下格式

{0:dd/MM}

You could try the following format:

{0:dd/MM}
夜光 2024-10-12 09:49:52

您是否尝试过:

myDateTime.ToString(@"dd/MM");

Have you simply tried:

myDateTime.ToString(@"dd/MM");
无法言说的痛 2024-10-12 09:49:52

您确定它忽略您本地计算机的区域设置吗?

如果你这样做会发生什么:

Console.WriteLine(date1.ToString("M", CultureInfo.CreateSpecificCulture("en-US")));

Are you sure its ignoring your local computer regional settings ?

What happens if you do:

Console.WriteLine(date1.ToString("M", CultureInfo.CreateSpecificCulture("en-US")));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文