gpt4 book ai didi

vb.net - 在 vb.net 中以 dd/mm/yyyy 格式显示日期

转载 作者:行者123 更新时间:2023-12-04 00:01:42 24 4
gpt4 key购买 nike

我想以 09/07/2013 格式而不是 09-jul-13 格式显示日期。

Dim dt As Date = Date.Today

MsgBox(dt)

最佳答案

首先,大写的 MM 是月,小写的 mm 是分钟。

您必须通过CultureInfo.InvariantCultureToString确保/使用日期分隔符,因为它通常会被当前文化的日期分隔符替换:

MsgBox(dt.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture))

另一种选择是通过在 ' 中嵌入/来转义自定义格式说明符:
dt.ToString("dd'/'MM'/'yyyy")

MSDN: The "/" Custom Format Specifier :

The "/" custom format specifier represents the date separator, which is used to differentiate years, months, and days. The appropriate localized date separator is retrieved from the DateTimeFormatInfo.DateSeparator property of the current or specified culture.

关于vb.net - 在 vb.net 中以 dd/mm/yyyy 格式显示日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17546184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com