日期时间格式在vb.net中转换 [英] Date time format convert in vb.net

查看:174
本文介绍了日期时间格式在vb.net中转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个来源获取日期时间为20110731183330。我想将其转换为 2011年7月31日下午06:33:30。在vb.net中是否有相同的一行代码?

I'm getting date-time from a source as 20110731183330. I want to convert it to '7/31/2011 06:33:30 PM'. Is there a one line code for the same in vb.net?

推荐答案

Dim result As Date = Date.ParseExact(dt, "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture)

然后我们可以根据需要设置其格式。

then we can format it as required.

这篇关于日期时间格式在vb.net中转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆