gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 08:43:22 25 4
gpt4 key购买 nike

这是我在 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/

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