在vb.net中如何获得当前时间

limengchen 2002-11-06 01:36:10
以前是用Time来获取的,现在好像没有了,只剩下Now函数,但它返回的是日期+时间。
另外,再问几个问题:
1.utcTime是什么?
2.System().DateTime中有很多成员,但在代码窗口的自动完成功能中却只显示其中的几个,
为什么?
...全文
1371 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
limengchen 2002-11-08
  • 打赏
  • 举报
回复
最后那个问题呢?为什么没人回答?
sumtec 2002-11-08
  • 打赏
  • 举报
回复
因为DateTime是一个类,对于静态成员函数,你可以通过DateTime去访问。但是对于其他非静态的函数,你指能够通过DateTime的具体实例去访问。也就是说必须订一个DateTime类型的变量(对象),然后才能够访问,如:
Dim d As DateTime
d.xxx <- 这个时候就能见到所有公共的函数了。
limengchen 2002-11-08
  • 打赏
  • 举报
回复
2.System().DateTime中有很多成员,但在代码窗口的自动完成功能中却只显示其中的几个,
为什么?
池塘边的榕树 2002-11-08
  • 打赏
  • 举报
回复
1.utcTime是什么?格林威治时间
池塘边的榕树 2002-11-08
  • 打赏
  • 举报
回复
Format(Now, "hh:mm:ss")
liwowo 2002-11-06
  • 打赏
  • 举报
回复
Imports System
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential)> _
Public Class SystemTime

Public year As Short
Public month As Short
Public dayOfWeek As Short
Public day As Short
Public hour As Short
Public minute As Short
Public second As Short
Public milliseconds As Short

End Class 'SystemTime


Public Class LibWrap

'VOID GetSystemTime(LPSYSTEMTIME lpSystemTime)

Declare Sub GetSystemTime Lib "Kernel32.dll" (<[In](), Out()> ByVal st As SystemTime)

End Class 'LibWrap

然后在你所操作的class中调用就行了!!!
例如:
class sss
Private Function create_id() As String
Dim st As New SystemTime()
LibWrap.GetSystemTime(st)
Dim yy As String = st.year
Dim mm As String = st.month
Dim dd As String = st.day
Dim hh As String = st.hour
Dim m As String = st.minute
Dim ss As String = st.second
Dim ms As String = st.milliseconds
end function

end class

无耐的开心 2002-11-06
  • 打赏
  • 举报
回复
uctTime 获取一个 DateTime,它是以协调通用时间 (UTC) 表示的此计算机上的当前本地日期和时间。
Dim MyDateTime As Date = #1/27/2001 5:04:23 PM#
Dim MyStr As String
MyStr = Format(MyDateTime, "h:m:s") ' Returns "5:4:23".

limengchen 2002-11-06
  • 打赏
  • 举报
回复
哪个函数或属性?
无耐的开心 2002-11-06
  • 打赏
  • 举报
回复
System().DateTime中有反回你要的时间
uctcTime不知道

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧