尝试在 vb.net 2005 中将字符串转换为日期时间格式
我似乎无法将包含日期值“100714 0700”(2010-07-14 7am)的字符串转换为 vb.net 2005 中的日期格式
当我尝试执行以下操作时:
Dim provider As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture
strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yymmdd", provider)
我返回“1/ 14/2010 12:07:00 上午"
如何获得“2010-07-14 7:00”的值?
I can't seem to be able to convert a string that contains date value of "100714 0700" (2010-07-14 7am) to a date format in vb.net 2005
When I attempt to do:
Dim provider As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture
strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yymmdd", provider)
I get back "1/14/2010 12:07:00 AM"
How can I get a value of "2010-07-14 7:00" ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是此处的另一个链接,展示了如何在 C# 中执行此操作
将字符串转换为日期在 .NET 中,如果我的传入日期格式为 YYYYMMDD
在您的情况下,您可能还想添加时间格式:
Here is another link from here on SO that shows how to do this in C#
Convert String to Date in .NET if my incoming date format is in YYYYMMDD
In your case you probably also want add the time format:
抱歉,我上次快速阅读了这个问题,嗯,您是否尝试过类似
strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yy" & "-" & "-" & "mm" & “-”和“dd”,提供商)
Sorry, I read the question to quickly last time, hmmm have you tried something like
strPickupDateTime = DateTime.ParseExact(txtPickupDate.Text, "yy" & "-" & "-" & "mm" & "-" & "dd", provider)