vb.net - 在 Vb.net 中转换日期时间格式

标签 vb.net visual-studio datetime

这是我在 Excel 中的日期时间数据

3/10/2014  11:59:59 AM

我想在 vb.net 中将它转换成这样

  // I have a variable that contains the datetime like this

   Dim audit_date as DateTime = 3/10/2014 11:59:59 AM // and i want to convert this to the one below

   Output = 2014-03-10 11:59:59

我也想删除 AM/PM

最佳答案

你可以这样使用

Dim res As string=DateTime.Now.Tostring("yyyy-MM-dd hh:mm:ss")

编辑:

Dim res As string=Convert.ToDateTime("3/10/2014  11:59:59 AM").Tostring("yyyy-MM-dd hh:mm:ss")

我希望这会有所帮助。

关于vb.net - 在 Vb.net 中转换日期时间格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22397856/

相关文章:

.net - 比较 Nodatime 中不同时区的 LocalDateTime

c# - 无法在 Visual Studio 中为 UWP 应用程序设置 "User Notification Listener"功能

wpf - 如何让 MSIX 应用安装程序在每次生成/发布期间输出正确的设置?

c# - Linq where 子句只比较没有时间值的日期值

.net - Quartz 在运行后编译作业脚本?

mysql - 显示数据从dataGrid到Crystal report vb.net

vb.net - "Not ... Is Nothing"与 "... IsNot Nothing"

visual-studio - CMakeLists.txt 的 Visual Studio Code 语法高亮显示

Mysql查询混合日期时间和位置

c# - 计算生日的剩余天数?